From 5ed508ae34ac03c9ac7bbcd2e786d0ef7fc0e17f Mon Sep 17 00:00:00 2001 From: CaS Date: Sun, 6 Oct 2002 06:12:20 +0000 Subject: [PATCH] Memory management fix git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14657 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSData.m | 20 ++++---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 324fb0566..6ccb39edf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-10-06 Richard Frith-Macdonald + + * 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 * Source/NSData.m ([NSDataMappedFile diff --git a/Source/NSData.m b/Source/NSData.m index 27c58fdb7..f32736144 100644 --- a/Source/NSData.m +++ b/Source/NSData.m @@ -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",