mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 18:21:04 +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
|
@ -6,6 +6,9 @@
|
||||||
* Source/NSConnection.m: When creating a connection and getting its
|
* Source/NSConnection.m: When creating a connection and getting its
|
||||||
proxy, release the connection immediately if the proxy is nil, so
|
proxy, release the connection immediately if the proxy is nil, so
|
||||||
that repeated calls don't use more resources.
|
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>
|
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++)
|
for (i = 0; i < released->count; i++)
|
||||||
{
|
{
|
||||||
id anObject = objects[i];
|
id anObject;
|
||||||
Class c = GSObjCClass(anObject);
|
Class c;
|
||||||
unsigned hash = (((unsigned)(uintptr_t)c) >> 3) & 0x0f;
|
unsigned hash;
|
||||||
|
|
||||||
|
anObject = objects[i];
|
||||||
objects[i] = nil;
|
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)
|
if (classes[hash] != c)
|
||||||
{
|
{
|
||||||
classes[hash] = c;
|
IMP imp;
|
||||||
|
|
||||||
if (GSObjCIsInstance(anObject))
|
if (GSObjCIsInstance(anObject))
|
||||||
{
|
{
|
||||||
imps[hash] = [c instanceMethodForSelector: releaseSel];
|
imp = [c instanceMethodForSelector: releaseSel];
|
||||||
}
|
}
|
||||||
else
|
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);
|
(imps[hash])(anObject, releaseSel);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue