mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +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
0b6c65c4cc
commit
566d6ed569
2 changed files with 31 additions and 6 deletions
|
@ -6,6 +6,9 @@
|
|||
* Source/NSConnection.m: When creating a connection and getting its
|
||||
proxy, release the connection immediately if the proxy is nil, so
|
||||
that repeated calls don't use more resources.
|
||||
* Source/NSNSAutoreleasePool.m: When emptying pool, add diagnostic
|
||||
message and exceptions where an object we are releasing is bad in
|
||||
some way.
|
||||
|
||||
2008-02-17 19:21-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
|
|
|
@ -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…
Reference in a new issue