mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Memory management fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16421 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a18e9de578
commit
856e8a4598
3 changed files with 9 additions and 19 deletions
|
@ -9,7 +9,9 @@
|
|||
* Source/NSArchiver.m: Structure encoding/decoding fixes.
|
||||
* Source/NSData.m: Structure encoding/decoding fixes.
|
||||
* Source/NSPortCoder.m: Structure encoding/decoding fixes.
|
||||
Manage memory used by decoded pointers (including c-strings).
|
||||
* Source/NSUnarchiver.m: Structure encoding/decoding fixes.
|
||||
* Source/NSConnectiom.m: Don't try to autorelease decoded pointers.
|
||||
|
||||
2003-04-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -1759,10 +1759,6 @@ static void retDecoder(DOContext *ctxt)
|
|||
else
|
||||
{
|
||||
[coder decodeValueOfObjCType: type at: ctxt->datum];
|
||||
if ((*type == _C_CHARPTR || *type == _C_PTR) && *(void**)ctxt->datum != 0)
|
||||
{
|
||||
[NSData dataWithBytesNoCopy: *(void**)ctxt->datum length: 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2303,19 +2299,7 @@ static void callDecoder (DOContext *ctxt)
|
|||
}
|
||||
else
|
||||
{
|
||||
void *datum = ctxt->datum;
|
||||
|
||||
[ctxt->decoder decodeValueOfObjCType: type at: datum];
|
||||
/*
|
||||
* -decodeValueOfObjCType:at: malloc's new memory
|
||||
* for pointers. We need to make sure it gets freed eventually
|
||||
* so we don't have a memory leak. Request here that it be
|
||||
* autorelease'ed.
|
||||
*/
|
||||
if ((*type == _C_CHARPTR || *type == _C_PTR) && *(void**)datum != 0)
|
||||
{
|
||||
[NSData dataWithBytesNoCopy: *(void**)datum length: 1];
|
||||
}
|
||||
[ctxt->decoder decodeValueOfObjCType: type at: ctxt->datum];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -821,14 +821,18 @@ static IMP _xRefImp; /* Serialize a crossref. */
|
|||
}
|
||||
else
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
if (xref != GSIArrayCount(_ptrAry))
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"extra string crossref - %d", xref];
|
||||
}
|
||||
(*_dDesImp)(_src, dDesSel, address, @encode(char*), &_cursor,
|
||||
nil);
|
||||
(*_dDesImp)(_src, dDesSel, &tmp, @encode(char*), &_cursor, nil);
|
||||
*(void**)address = GSAutoreleasedBuffer(strlen(tmp)+1);
|
||||
GSIArrayAddItem(_ptrAry, (GSIArrayItem)*(void**)address);
|
||||
strcpy(*(char**)address, tmp);
|
||||
NSZoneFree(NSDefaultMallocZone(), tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue