mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Memory management fix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14657 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
083c3a2dc6
commit
f6963c9041
2 changed files with 9 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
|||
2002-10-06 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSData.m: readContentsOfFile() fix use of atomic memory
|
||||
on GC systems ... problem noticed by Fred.
|
||||
|
||||
Sat Oct 5 19:53:03 2002 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSData.m ([NSDataMappedFile
|
||||
|
|
|
@ -141,6 +141,10 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
unsigned fileLength;
|
||||
#endif
|
||||
|
||||
#if GS_WITH_GC == 1
|
||||
zone = GSAtomicMallocZone(); // Use non-GC memory inside NSData
|
||||
#endif
|
||||
|
||||
if ([path getFileSystemRepresentation: thePath
|
||||
maxLength: sizeof(thePath)-1] == NO)
|
||||
{
|
||||
|
@ -174,11 +178,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
return NO;
|
||||
}
|
||||
|
||||
#if GS_WITH_GC == 1
|
||||
tmp = NSZoneMalloc(GSAtomicMallocZone(), fileLength);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, fileLength);
|
||||
#endif
|
||||
if (tmp == 0)
|
||||
{
|
||||
NSWarnFLog(@"Malloc failed for file (%s) of length %d - %s",
|
||||
|
@ -267,19 +267,11 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
{
|
||||
if (tmp == 0)
|
||||
{
|
||||
#if GS_WITH_GC == 1
|
||||
tmp = NSZoneMalloc(GSAtomicMallocZone(), c);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, c);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if GS_WITH_GC == 1
|
||||
tmp = NSZoneRealloc(GSAtomicMallocZone(), tmp, fileLength + c);
|
||||
#else
|
||||
tmp = NSZoneRealloc(zone, tmp, fileLength + c);
|
||||
#endif
|
||||
}
|
||||
if (tmp == 0)
|
||||
{
|
||||
|
@ -293,11 +285,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if GS_WITH_GC == 1
|
||||
tmp = NSZoneMalloc(GSAtomicMallocZone(), fileLength);
|
||||
#else
|
||||
tmp = NSZoneMalloc(zone, fileLength);
|
||||
#endif
|
||||
if (tmp == 0)
|
||||
{
|
||||
NSWarnFLog(@"Malloc failed for file (%s) of length %d - %s",
|
||||
|
|
Loading…
Reference in a new issue