mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
fix memory leak
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28448 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fbb35d1684
commit
10d2d0016c
2 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
|||
2009-08-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSData.m: Fix memory leak introduced with GC changes.
|
||||
|
||||
2009-08-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSFileManager.m:
|
||||
|
|
|
@ -3699,25 +3699,30 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
|
||||
#if GS_WITH_GC
|
||||
tmp = NSAllocateCollectable(size, 0);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, size);
|
||||
#endif
|
||||
if (tmp == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"Unable to set data capacity to '%d'", size];
|
||||
}
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
memcpy(tmp, bytes, capacity < size ? capacity : size);
|
||||
#if GS_WITH_GC
|
||||
if (owned == YES)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), bytes);
|
||||
owned = NO;
|
||||
}
|
||||
}
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, size);
|
||||
if (tmp == 0)
|
||||
{
|
||||
[NSException raise: NSMallocException
|
||||
format: @"Unable to set data capacity to '%d'", size];
|
||||
}
|
||||
if (bytes)
|
||||
{
|
||||
memcpy(tmp, bytes, capacity < size ? capacity : size);
|
||||
if (zone == 0)
|
||||
{
|
||||
zone = NSDefaultMallocZone();
|
||||
|
@ -3726,8 +3731,12 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
|||
{
|
||||
NSZoneFree(zone, bytes);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (zone == 0)
|
||||
{
|
||||
zone = NSDefaultMallocZone();
|
||||
}
|
||||
#endif
|
||||
bytes = tmp;
|
||||
capacity = size;
|
||||
growth = capacity/2;
|
||||
|
|
Loading…
Reference in a new issue