mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +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
97be67439f
commit
792fce302f
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>
|
2009-08-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSFileManager.m:
|
* Source/NSFileManager.m:
|
||||||
|
|
|
@ -3699,25 +3699,30 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
||||||
|
|
||||||
#if GS_WITH_GC
|
#if GS_WITH_GC
|
||||||
tmp = NSAllocateCollectable(size, 0);
|
tmp = NSAllocateCollectable(size, 0);
|
||||||
#else
|
|
||||||
tmp = NSZoneMalloc(zone, size);
|
|
||||||
#endif
|
|
||||||
if (tmp == 0)
|
if (tmp == 0)
|
||||||
{
|
{
|
||||||
[NSException raise: NSMallocException
|
[NSException raise: NSMallocException
|
||||||
format: @"Unable to set data capacity to '%d'", size];
|
format: @"Unable to set data capacity to '%d'", size];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes)
|
if (bytes)
|
||||||
{
|
{
|
||||||
memcpy(tmp, bytes, capacity < size ? capacity : size);
|
memcpy(tmp, bytes, capacity < size ? capacity : size);
|
||||||
#if GS_WITH_GC
|
|
||||||
if (owned == YES)
|
if (owned == YES)
|
||||||
{
|
{
|
||||||
NSZoneFree(NSDefaultMallocZone(), bytes);
|
NSZoneFree(NSDefaultMallocZone(), bytes);
|
||||||
owned = NO;
|
owned = NO;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#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)
|
if (zone == 0)
|
||||||
{
|
{
|
||||||
zone = NSDefaultMallocZone();
|
zone = NSDefaultMallocZone();
|
||||||
|
@ -3726,8 +3731,12 @@ getBytes(void* dst, void* src, unsigned len, unsigned limit, unsigned *pos)
|
||||||
{
|
{
|
||||||
NSZoneFree(zone, bytes);
|
NSZoneFree(zone, bytes);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
else if (zone == 0)
|
||||||
|
{
|
||||||
|
zone = NSDefaultMallocZone();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
bytes = tmp;
|
bytes = tmp;
|
||||||
capacity = size;
|
capacity = size;
|
||||||
growth = capacity/2;
|
growth = capacity/2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue