mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Add some diagnostics for memory management errors (deallocating a deallocated
object). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26085 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4daa8d64f8
commit
aa3dfae174
2 changed files with 31 additions and 6 deletions
|
@ -385,22 +385,44 @@ static IMP initImp;
|
|||
|
||||
for (i = 0; i < released->count; i++)
|
||||
{
|
||||
id anObject = objects[i];
|
||||
Class c = GSObjCClass(anObject);
|
||||
unsigned hash = (((unsigned)(uintptr_t)c) >> 3) & 0x0f;
|
||||
id anObject;
|
||||
Class c;
|
||||
unsigned hash;
|
||||
|
||||
anObject = objects[i];
|
||||
objects[i] = nil;
|
||||
if (anObject == nil)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"nil object encountered in autorelease pool\n");
|
||||
continue;
|
||||
}
|
||||
c = GSObjCClass(anObject);
|
||||
if (c == 0)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"nul class for object in autorelease pool"];
|
||||
}
|
||||
hash = (((unsigned)(uintptr_t)c) >> 3) & 0x0f;
|
||||
if (classes[hash] != c)
|
||||
{
|
||||
classes[hash] = c;
|
||||
IMP imp;
|
||||
|
||||
if (GSObjCIsInstance(anObject))
|
||||
{
|
||||
imps[hash] = [c instanceMethodForSelector: releaseSel];
|
||||
imp = [c instanceMethodForSelector: releaseSel];
|
||||
}
|
||||
else
|
||||
{
|
||||
imps[hash] = [c methodForSelector: releaseSel];
|
||||
imp = [c methodForSelector: releaseSel];
|
||||
}
|
||||
if (imp == 0)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"nul release for object in autorelease pool"];
|
||||
}
|
||||
classes[hash] = c;
|
||||
imps[hash] = imp;
|
||||
}
|
||||
(imps[hash])(anObject, releaseSel);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue