minor cleanups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32234 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2011-02-19 19:42:42 +00:00
parent b1eb86d5b4
commit ca854a4b3c
16 changed files with 93 additions and 74 deletions

View file

@ -1,3 +1,23 @@
2011-02-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSBundle.m:
* Source/NSProcessInfo.m:
* Source/NSConcretePointerFunctions.m:
* Source/GSFFCallInvocation.m:
* Source/NSZone.m:
* Source/NSCallBacks.m:
* Source/win32/NSMessagePortNameServer.m:
* Source/NSFileManager.m:
* Source/NSURLProtocol.m:
* Source/objc-load.m:
* Source/NSException.m:
* Source/cifframe.m:
* Source/NSLog.m:
* Tools/defaults.m:
* Tests/base/NSInvocation/Resources/InvokeProxy.m:
Remove obsolete calls to objc_malloc() in favour of NSZoneMalloc() or
malloc() where using zones is not appropriate.
2011-02-19 Richard Frith-Macdonald <rfm@gnu.org> 2011-02-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSFFCallInvocation.m: Updated two obsolete runtime calls * Source/GSFFCallInvocation.m: Updated two obsolete runtime calls

View file

@ -493,7 +493,7 @@ static IMP gs_objc_msg_forward (SEL sel)
// 2.b.2 NO, we do not have it. // 2.b.2 NO, we do not have it.
vacallReturnTypeInfo *ret_info; vacallReturnTypeInfo *ret_info;
ret_info = objc_malloc (sizeof (vacallReturnTypeInfo)); ret_info = malloc(sizeof (vacallReturnTypeInfo));
*ret_info = returnInfo; *ret_info = returnInfo;
forwarding_callback forwarding_callback

View file

@ -885,14 +885,14 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
while (numClasses < newNumClasses) while (numClasses < newNumClasses)
{ {
numClasses = newNumClasses; numClasses = newNumClasses;
classes = objc_realloc(classes, sizeof(Class) * numClasses); classes = realloc(classes, sizeof(Class) * numClasses);
newNumClasses = objc_getClassList(classes, numClasses); newNumClasses = objc_getClassList(classes, numClasses);
} }
for (i = 0; i < numClasses; i++) for (i = 0; i < numClasses; i++)
{ {
[self _addFrameworkFromClass: classes[i]]; [self _addFrameworkFromClass: classes[i]];
} }
objc_free(classes); free(classes);
} }
#else #else
{ {

View file

@ -93,7 +93,7 @@ void
_NS_owned_void_p_release(void *table, void *p) _NS_owned_void_p_release(void *table, void *p)
{ {
if (p != 0) if (p != 0)
objc_free(p); free(p);
return; return;
} }

View file

@ -33,7 +33,7 @@ acquireMallocMemory(const void *item,
if (shouldCopy == YES) if (shouldCopy == YES)
{ {
NSUInteger len = (*size)(item); NSUInteger len = (*size)(item);
void *newItem = objc_malloc(len); void *newItem = malloc(len);
memcpy(newItem, item, len); memcpy(newItem, item, len);
item = newItem; item = newItem;
@ -161,7 +161,7 @@ static void
relinquishMallocMemory(const void *item, relinquishMallocMemory(const void *item,
NSUInteger (*size)(const void *item)) NSUInteger (*size)(const void *item))
{ {
objc_free((void*)item); free((void*)item);
} }
static void static void

View file

@ -293,7 +293,7 @@ GSPrivateBaseAddress(void *addr, void **base)
} }
if (_symbols) if (_symbols)
{ {
objc_free (_symbols); free(_symbols);
_symbols = NULL; _symbols = NULL;
} }
[super dealloc]; [super dealloc];
@ -359,7 +359,7 @@ GSPrivateBaseAddress(void *addr, void **base)
DESTROY(self); DESTROY(self);
return nil; return nil;
} }
_symbols = objc_malloc (neededSpace); _symbols = malloc (neededSpace);
if (!_symbols) if (!_symbols)
{ {
//NSLog (@"GSBinaryFileInfo: Can't allocate buffer"); //NSLog (@"GSBinaryFileInfo: Can't allocate buffer");

View file

@ -993,7 +993,7 @@ static NSStringEncoding defaultEncoding;
int len = GetCurrentDirectoryW(0, 0); int len = GetCurrentDirectoryW(0, 0);
if (len > 0) if (len > 0)
{ {
_CHAR *lpath = (_CHAR*)objc_calloc(len+10,sizeof(_CHAR)); _CHAR *lpath = (_CHAR*)calloc(len+10,sizeof(_CHAR));
if (lpath != 0) if (lpath != 0)
{ {
@ -1006,7 +1006,7 @@ static NSStringEncoding defaultEncoding;
path = [NSString stringWithCharacters: lpath length: len]; path = [NSString stringWithCharacters: lpath length: len];
currentDir = path; currentDir = path;
} }
objc_free(lpath); free(lpath);
} }
} }
#else #else

View file

@ -173,13 +173,13 @@ _NSLog_standard_printf_handler (NSString* message)
if (GSPrivateDefaultsFlag(GSLogSyslog) == YES if (GSPrivateDefaultsFlag(GSLogSyslog) == YES
|| write(_NSLogDescriptor, buf, len) != (int)len) || write(_NSLogDescriptor, buf, len) != (int)len)
{ {
null_terminated_buf = objc_malloc (sizeof (char) * (len + 1)); null_terminated_buf = malloc(sizeof (char) * (len + 1));
strncpy (null_terminated_buf, buf, len); strncpy (null_terminated_buf, buf, len);
null_terminated_buf[len] = '\0'; null_terminated_buf[len] = '\0';
syslog(SYSLOGMASK, "%s", null_terminated_buf); syslog(SYSLOGMASK, "%s", null_terminated_buf);
objc_free (null_terminated_buf); free(null_terminated_buf);
} }
#else #else
write(_NSLogDescriptor, buf, len); write(_NSLogDescriptor, buf, len);

View file

@ -231,12 +231,12 @@ _gnu_process_args(int argc, char *argv[], char *env[])
if (_gnu_arg_zero != 0) if (_gnu_arg_zero != 0)
{ {
objc_free(_gnu_arg_zero); free(_gnu_arg_zero);
} }
if (argv != 0 && argv[0] != 0) if (argv != 0 && argv[0] != 0)
{ {
_gnu_arg_zero = (char*)objc_malloc(strlen(argv[0]) + 1); _gnu_arg_zero = (char*)malloc(strlen(argv[0]) + 1);
strcpy(_gnu_arg_zero, argv[0]); strcpy(_gnu_arg_zero, argv[0]);
arg0 = [[NSString alloc] initWithCString: _gnu_arg_zero]; arg0 = [[NSString alloc] initWithCString: _gnu_arg_zero];
} }
@ -251,7 +251,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
while (needed_size == buffer_size) while (needed_size == buffer_size)
{ {
buffer_size = buffer_size + 256; buffer_size = buffer_size + 256;
buffer = (unichar*)objc_malloc(buffer_size * sizeof(unichar)); buffer = (unichar*)malloc(buffer_size * sizeof(unichar));
needed_size = GetModuleFileNameW(NULL, buffer, buffer_size); needed_size = GetModuleFileNameW(NULL, buffer, buffer_size);
if (needed_size < buffer_size) if (needed_size < buffer_size)
{ {
@ -268,11 +268,11 @@ _gnu_process_args(int argc, char *argv[], char *env[])
} }
else else
{ {
objc_free(buffer); free(buffer);
} }
} }
tmp = [arg0 cStringUsingEncoding: [NSString defaultCStringEncoding]]; tmp = [arg0 cStringUsingEncoding: [NSString defaultCStringEncoding]];
_gnu_arg_zero = (char*)objc_malloc(strlen(tmp) + 1); _gnu_arg_zero = (char*)malloc(strlen(tmp) + 1);
strcpy(_gnu_arg_zero, tmp); strcpy(_gnu_arg_zero, tmp);
#else #else
fprintf(stderr, "Error: for some reason, argv not properly set up " fprintf(stderr, "Error: for some reason, argv not properly set up "
@ -511,7 +511,7 @@ static char **_gnu_noobjc_env = NULL;
/* copy the environment strings */ /* copy the environment strings */
for (count = 0; vectors[count]; count++) for (count = 0; vectors[count]; count++)
; ;
_gnu_noobjc_env = (char**)objc_malloc(sizeof(char*) * (count + 1)); _gnu_noobjc_env = (char**)malloc(sizeof(char*) * (count + 1));
if (!_gnu_noobjc_env) if (!_gnu_noobjc_env)
goto malloc_error; goto malloc_error;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -539,7 +539,7 @@ static char **_gnu_noobjc_env = NULL;
for (_gnu_noobjc_argc = 0; vectors[_gnu_noobjc_argc]; _gnu_noobjc_argc++) for (_gnu_noobjc_argc = 0; vectors[_gnu_noobjc_argc]; _gnu_noobjc_argc++)
; ;
_gnu_noobjc_argv _gnu_noobjc_argv
= (char**)objc_malloc(sizeof(char*) * (_gnu_noobjc_argc + 1)); = (char**)malloc(sizeof(char*) * (_gnu_noobjc_argc + 1));
if (!_gnu_noobjc_argv) if (!_gnu_noobjc_argv)
goto malloc_error; goto malloc_error;
for (i = 0; i < _gnu_noobjc_argc; i++) for (i = 0; i < _gnu_noobjc_argc; i++)
@ -559,7 +559,7 @@ static char **_gnu_noobjc_env = NULL;
int i, count; int i, count;
// Read commandline // Read commandline
proc_file_name = (char*)objc_malloc(sizeof(char) * 2048); proc_file_name = (char*)malloc(sizeof(char) * 2048);
sprintf(proc_file_name, "/proc/%d/psinfo", (int)getpid()); sprintf(proc_file_name, "/proc/%d/psinfo", (int)getpid());
ifp = fopen(proc_file_name, "r"); ifp = fopen(proc_file_name, "r");
@ -585,7 +585,7 @@ static char **_gnu_noobjc_env = NULL;
/* copy the environment strings */ /* copy the environment strings */
for (count = 0; vectors[count]; count++) for (count = 0; vectors[count]; count++)
; ;
_gnu_noobjc_env = (char**)objc_malloc(sizeof(char*) * (count + 1)); _gnu_noobjc_env = (char**)malloc(sizeof(char*) * (count + 1));
if (!_gnu_noobjc_env) if (!_gnu_noobjc_env)
goto malloc_error; goto malloc_error;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
@ -607,7 +607,7 @@ static char **_gnu_noobjc_env = NULL;
for (_gnu_noobjc_argc = 0; vectors[_gnu_noobjc_argc]; _gnu_noobjc_argc++) for (_gnu_noobjc_argc = 0; vectors[_gnu_noobjc_argc]; _gnu_noobjc_argc++)
; ;
_gnu_noobjc_argv _gnu_noobjc_argv
= (char**)objc_malloc(sizeof(char*) * (_gnu_noobjc_argc + 1)); = (char**)malloc(sizeof(char*) * (_gnu_noobjc_argc + 1));
if (!_gnu_noobjc_argv) if (!_gnu_noobjc_argv)
goto malloc_error; goto malloc_error;
for (i = 0; i < _gnu_noobjc_argc; i++) for (i = 0; i < _gnu_noobjc_argc; i++)
@ -656,7 +656,7 @@ static char **_gnu_noobjc_env = NULL;
while (environ[c] != NULL) while (environ[c] != NULL)
c++; c++;
env_terms = c; env_terms = c;
_gnu_noobjc_env = (char**)objc_malloc(sizeof(char*) * (env_terms + 1)); _gnu_noobjc_env = (char**)malloc(sizeof(char*) * (env_terms + 1));
if (_gnu_noobjc_env == NULL) if (_gnu_noobjc_env == NULL)
goto malloc_error; goto malloc_error;
for (c = 0; c < env_terms; c++) for (c = 0; c < env_terms; c++)
@ -668,7 +668,7 @@ static char **_gnu_noobjc_env = NULL;
_gnu_noobjc_env[c] = NULL; _gnu_noobjc_env[c] = NULL;
// Read commandline // Read commandline
proc_file_name = (char *)objc_malloc(sizeof(char) * 2048); proc_file_name = (char *)malloc(sizeof(char) * 2048);
sprintf(proc_file_name, "/proc/%d/cmdline", (int)getpid()); sprintf(proc_file_name, "/proc/%d/cmdline", (int)getpid());
/* /*
@ -701,8 +701,7 @@ static char **_gnu_noobjc_env = NULL;
* Now _gnu_noobcj_argc is the number of arguments; * Now _gnu_noobcj_argc is the number of arguments;
* allocate memory accordingly. * allocate memory accordingly.
*/ */
_gnu_noobjc_argv _gnu_noobjc_argv = (char **)malloc((sizeof(char *)) * (_gnu_noobjc_argc + 1));
= (char **)objc_malloc((sizeof(char *)) * (_gnu_noobjc_argc + 1));
if (_gnu_noobjc_argv == NULL) if (_gnu_noobjc_argv == NULL)
goto malloc_error; goto malloc_error;
@ -711,7 +710,7 @@ static char **_gnu_noobjc_env = NULL;
//freopen(proc_file_name, "r", ifp); //freopen(proc_file_name, "r", ifp);
if (ifp == NULL) if (ifp == NULL)
{ {
objc_free(_gnu_noobjc_argv); free(_gnu_noobjc_argv);
goto proc_fs_error; goto proc_fs_error;
} }
argument = 0; argument = 0;
@ -723,7 +722,7 @@ static char **_gnu_noobjc_env = NULL;
if ((c == EOF) || (c == 0)) // End of a parameter if ((c == EOF) || (c == 0)) // End of a parameter
{ {
_gnu_noobjc_argv[argument] _gnu_noobjc_argv[argument]
= (char*)objc_malloc((sizeof(char))*length); = (char*)malloc((sizeof(char))*length);
if (_gnu_noobjc_argv[argument] == NULL) if (_gnu_noobjc_argv[argument] == NULL)
goto malloc_error; goto malloc_error;
argument++; argument++;
@ -738,8 +737,8 @@ static char **_gnu_noobjc_env = NULL;
if (ifp == NULL) if (ifp == NULL)
{ {
for (c = 0; c < _gnu_noobjc_argc; c++) for (c = 0; c < _gnu_noobjc_argc; c++)
objc_free(_gnu_noobjc_argv[c]); free(_gnu_noobjc_argv[c]);
objc_free(_gnu_noobjc_argv); free(_gnu_noobjc_argv);
goto proc_fs_error; goto proc_fs_error;
} }
argument = 0; argument = 0;
@ -771,7 +770,7 @@ static char **_gnu_noobjc_env = NULL;
} }
_gnu_noobjc_argv[argument] = NULL; _gnu_noobjc_argv[argument] = NULL;
fclose(ifp); fclose(ifp);
objc_free(proc_file_name); free(proc_file_name);
return; return;
proc_fs_error: proc_fs_error:
@ -791,7 +790,7 @@ static char **_gnu_noobjc_env = NULL;
#ifdef HAVE_PROGRAM_INVOCATION_NAME #ifdef HAVE_PROGRAM_INVOCATION_NAME
fprintf(stderr, "We try to go on anyway; but the program will ignore any argument which were passed to it.\n"); fprintf(stderr, "We try to go on anyway; but the program will ignore any argument which were passed to it.\n");
_gnu_noobjc_argc = 1; _gnu_noobjc_argc = 1;
_gnu_noobjc_argv = objc_malloc(sizeof(char *) * 2); _gnu_noobjc_argv = malloc(sizeof(char *) * 2);
if (_gnu_noobjc_argv == NULL) if (_gnu_noobjc_argv == NULL)
goto malloc_error; goto malloc_error;
_gnu_noobjc_argv[0] = strdup(program_invocation_name); _gnu_noobjc_argv[0] = strdup(program_invocation_name);
@ -809,7 +808,7 @@ static char **_gnu_noobjc_env = NULL;
#endif /* HAVE_PROGRAM_INVOCATION_NAME */ #endif /* HAVE_PROGRAM_INVOCATION_NAME */
#endif /* !HAVE_KVM_ENV (e.g. HAVE_PROCFS) */ #endif /* !HAVE_KVM_ENV (e.g. HAVE_PROCFS) */
malloc_error: malloc_error:
fprintf(stderr, "objc_malloc() error when starting gnustep-base.\n"); fprintf(stderr, "malloc() error when starting gnustep-base.\n");
fprintf(stderr, "Free some memory and then re-run the program.\n"); fprintf(stderr, "Free some memory and then re-run the program.\n");
abort(); abort();
} }
@ -822,19 +821,19 @@ _gnu_noobjc_free_vars(void)
p = _gnu_noobjc_argv; p = _gnu_noobjc_argv;
while (*p) while (*p)
{ {
objc_free(*p); free(*p);
p++; p++;
} }
objc_free(_gnu_noobjc_argv); free(_gnu_noobjc_argv);
_gnu_noobjc_argv = 0; _gnu_noobjc_argv = 0;
p = _gnu_noobjc_env; p = _gnu_noobjc_env;
while (*p) while (*p)
{ {
objc_free(*p); free(*p);
p++; p++;
} }
objc_free(_gnu_noobjc_env); free(_gnu_noobjc_env);
_gnu_noobjc_env = 0; _gnu_noobjc_env = 0;
} }

View file

@ -53,12 +53,12 @@
static void* static void*
zalloc(void *opaque, unsigned nitems, unsigned size) zalloc(void *opaque, unsigned nitems, unsigned size)
{ {
return objc_calloc(nitems, size); return calloc(nitems, size);
} }
static void static void
zfree(void *opaque, void *mem) zfree(void *opaque, void *mem)
{ {
objc_free(mem); free(mem);
} }
#else #else
# undef USE_ZLIB # undef USE_ZLIB

View file

@ -36,7 +36,7 @@
/* Actual design: /* Actual design:
- The default zone uses objc_malloc() and friends. We assume that - The default zone uses malloc() and friends. We assume that
they're thread safe and that they return NULL if we're out of they're thread safe and that they return NULL if we're out of
memory (glibc malloc does this, what about other mallocs? FIXME). memory (glibc malloc does this, what about other mallocs? FIXME).
@ -121,7 +121,7 @@ default_malloc (NSZone *zone, size_t size)
{ {
void *mem; void *mem;
mem = objc_malloc(size); mem = malloc(size);
if (mem == NULL) if (mem == NULL)
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"Default zone has run out of memory"]; format: @"Default zone has run out of memory"];
@ -135,18 +135,18 @@ default_realloc (NSZone *zone, void *ptr, size_t size)
if (size == 0) if (size == 0)
{ {
objc_free(ptr); free(ptr);
return NULL; return NULL;
} }
if (ptr == 0) if (ptr == 0)
{ {
mem = objc_malloc(size); mem = malloc(size);
if (mem == NULL) if (mem == NULL)
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"Default zone has run out of memory"]; format: @"Default zone has run out of memory"];
return mem; return mem;
} }
mem = objc_realloc(ptr, size); mem = realloc(ptr, size);
if (mem == NULL) if (mem == NULL)
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"Default zone has run out of memory"]; format: @"Default zone has run out of memory"];
@ -156,7 +156,7 @@ default_realloc (NSZone *zone, void *ptr, size_t size)
static void static void
default_free (NSZone *zone, void *ptr) default_free (NSZone *zone, void *ptr)
{ {
objc_free(ptr); free(ptr);
} }
static void static void
@ -170,7 +170,7 @@ default_recycle (NSZone *zone)
static BOOL static BOOL
default_check (NSZone *zone) default_check (NSZone *zone)
{ {
/* We can't check memory managed by objc_malloc(). */ /* We can't check memory managed by malloc(). */
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"No checking for default zone"]; format: @"No checking for default zone"];
return NO; return NO;
@ -188,7 +188,7 @@ default_stats (NSZone *zone)
{ {
struct NSZoneStats dummy = {0,0,0,0,0}; struct NSZoneStats dummy = {0,0,0,0,0};
/* We can't obtain statistics from the memory managed by objc_malloc(). */ /* We can't obtain statistics from the memory managed by malloc(). */
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"No statistics for default zone"]; format: @"No statistics for default zone"];
return dummy; return dummy;
@ -765,7 +765,7 @@ destroy_zone(NSZone* zone)
if (ptr) if (ptr)
ptr->next = zone->next; ptr->next = zone->next;
} }
objc_free((void*)zone); free((void*)zone);
} }
/* Search the buffer to see if there is any memory chunks large enough /* Search the buffer to see if there is any memory chunks large enough
@ -989,7 +989,7 @@ frecycle1(NSZone *zone)
tmp = tmp->next; tmp = tmp->next;
tmp->next = block->next; tmp->next = block->next;
} }
objc_free((void*)block); free((void*)block);
} }
block = nextblock; block = nextblock;
} }
@ -1277,7 +1277,7 @@ get_chunk (ffree_zone *zone, size_t size)
ff_block *block; ff_block *block;
blocksize = roundupto(size, zone->common.gran); blocksize = roundupto(size, zone->common.gran);
block = objc_malloc(blocksize+2*FBSZ); block = malloc(blocksize+2*FBSZ);
if (block == NULL) if (block == NULL)
return NULL; return NULL;
@ -1569,7 +1569,7 @@ nmalloc (NSZone *zone, size_t size)
{ {
size_t blocksize = roundupto(chunksize+NF_HEAD, zone->gran); size_t blocksize = roundupto(chunksize+NF_HEAD, zone->gran);
block = objc_malloc(blocksize); block = malloc(blocksize);
if (block == NULL) if (block == NULL)
{ {
pthread_mutex_unlock(&(zptr->lock)); pthread_mutex_unlock(&(zptr->lock));
@ -1610,7 +1610,7 @@ nrecycle1 (NSZone *zone)
while (block != NULL) while (block != NULL)
{ {
nextblock = block->next; nextblock = block->next;
objc_free(block); free(block);
block = nextblock; block = nextblock;
} }
zptr->blocks = 0; zptr->blocks = 0;
@ -1864,7 +1864,7 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree)
ff_block *chunk; ff_block *chunk;
ff_block *tailer; ff_block *tailer;
zone = objc_malloc(sizeof(ffree_zone)); zone = malloc(sizeof(ffree_zone));
if (zone == NULL) if (zone == NULL)
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"No memory to create zone"]; format: @"No memory to create zone"];
@ -1884,11 +1884,11 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree)
zone->segtaillist[i] = NULL; zone->segtaillist[i] = NULL;
} }
zone->bufsize = 0; zone->bufsize = 0;
zone->blocks = objc_malloc(startsize + 2*FBSZ); zone->blocks = malloc(startsize + 2*FBSZ);
if (zone->blocks == NULL) if (zone->blocks == NULL)
{ {
pthread_mutex_destroy(&(zone->lock)); pthread_mutex_destroy(&(zone->lock));
objc_free(zone); free(zone);
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"No memory to create zone"]; format: @"No memory to create zone"];
} }
@ -1919,7 +1919,7 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree)
nf_block *block; nf_block *block;
nfree_zone *zone; nfree_zone *zone;
zone = objc_malloc(sizeof(nfree_zone)); zone = malloc(sizeof(nfree_zone));
if (zone == NULL) if (zone == NULL)
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"No memory to create zone"]; format: @"No memory to create zone"];
@ -1933,12 +1933,12 @@ NSCreateZone (NSUInteger start, NSUInteger gran, BOOL canFree)
zone->common.gran = granularity; zone->common.gran = granularity;
zone->common.name = nil; zone->common.name = nil;
GS_INIT_RECURSIVE_MUTEX(zone->lock); GS_INIT_RECURSIVE_MUTEX(zone->lock);
zone->blocks = objc_malloc(startsize); zone->blocks = malloc(startsize);
zone->use = 0; zone->use = 0;
if (zone->blocks == NULL) if (zone->blocks == NULL)
{ {
pthread_mutex_destroy(&(zone->lock)); pthread_mutex_destroy(&(zone->lock));
objc_free(zone); free(zone);
[NSException raise: NSMallocException [NSException raise: NSMallocException
format: @"No memory to create zone"]; format: @"No memory to create zone"];
} }

View file

@ -438,7 +438,7 @@ cifframe_type(const char *typePtr, const char **advance)
{ {
size += (align - (size % align)); size += (align - (size % align));
} }
ftype = objc_malloc(size + (maxtypes+1)*sizeof(ffi_type)); ftype = malloc(size + (maxtypes+1)*sizeof(ffi_type));
ftype->size = 0; ftype->size = 0;
ftype->alignment = 0; ftype->alignment = 0;
ftype->type = FFI_TYPE_STRUCT; ftype->type = FFI_TYPE_STRUCT;
@ -455,7 +455,7 @@ cifframe_type(const char *typePtr, const char **advance)
if (types >= maxtypes) if (types >= maxtypes)
{ {
maxtypes *=2; maxtypes *=2;
ftype = objc_realloc(ftype, ftype = realloc(ftype,
size + (maxtypes+1)*sizeof(ffi_type)); size + (maxtypes+1)*sizeof(ffi_type));
ftype->elements = (void*)ftype + size; ftype->elements = (void*)ftype + size;
} }
@ -491,7 +491,7 @@ cifframe_type(const char *typePtr, const char **advance)
if (align > max_align) if (align > max_align)
{ {
if (ftype && ftype->type == FFI_TYPE_STRUCT) if (ftype && ftype->type == FFI_TYPE_STRUCT)
objc_free(ftype); free(ftype);
ftype = local; ftype = local;
max_align = align; max_align = align;
} }

View file

@ -282,7 +282,7 @@ GSPrivateSymbolPath(Class theClass, Category *theCategory)
{ {
if (len + sizeof(char)*19 > sizeof(buf)) if (len + sizeof(char)*19 > sizeof(buf))
{ {
p = objc_malloc(len + sizeof(char)*19); p = malloc(len + sizeof(char)*19);
if (p == NULL) if (p == NULL)
{ {
@ -300,7 +300,7 @@ GSPrivateSymbolPath(Class theClass, Category *theCategory)
if (len + sizeof(char)*23 > sizeof(buf)) if (len + sizeof(char)*23 > sizeof(buf))
{ {
p = objc_malloc(len + sizeof(char)*23); p = malloc(len + sizeof(char)*23);
if (p == NULL) if (p == NULL)
{ {
@ -321,7 +321,7 @@ GSPrivateSymbolPath(Class theClass, Category *theCategory)
if (p != buf) if (p != buf)
{ {
objc_free(p); free(p);
} }
if (ret) if (ret)

View file

@ -207,10 +207,10 @@ OutputDebugStringW(L"");
{ {
if (ptr != buf) if (ptr != buf)
{ {
objc_free(ptr); free(ptr);
} }
max += 1024; max += 1024;
ptr = objc_malloc(max); ptr = malloc(max);
len = max; len = max;
rc = RegQueryValueExW( rc = RegQueryValueExW(
key, key,
@ -224,7 +224,7 @@ OutputDebugStringW(L"");
{ {
if (ptr != buf) if (ptr != buf)
{ {
objc_free(ptr); free(ptr);
} }
return nil; return nil;
} }
@ -232,7 +232,7 @@ OutputDebugStringW(L"");
mailslotName = [NSString stringWithUTF8String: (const char *) ptr]; mailslotName = [NSString stringWithUTF8String: (const char *) ptr];
if (ptr != buf) if (ptr != buf)
{ {
objc_free(ptr); free(ptr);
} }
/* /*

View file

@ -153,10 +153,10 @@
d = [NSArchiver archivedDataWithRootObject: i]; d = [NSArchiver archivedDataWithRootObject: i];
i = [NSUnarchiver unarchiveObjectWithData: d]; i = [NSUnarchiver unarchiveObjectWithData: d];
l = [[i methodSignature] methodReturnLength]; l = [[i methodSignature] methodReturnLength];
b = (void *)objc_malloc(l); b = (void *)malloc(l);
[i getReturnValue: b]; [i getReturnValue: b];
[inv setReturnValue: b]; [inv setReturnValue: b];
objc_free(b); free(b);
#endif #endif
} }

View file

@ -481,7 +481,7 @@ main(int argc, char** argv, char **env)
int size = BUFSIZ; int size = BUFSIZ;
int got; int got;
int off = 0; int off = 0;
char *buf = objc_malloc(size); char *buf = malloc(size);
char *ptr; char *ptr;
/* /*
@ -492,7 +492,7 @@ main(int argc, char** argv, char **env)
{ {
off += BUFSIZ; off += BUFSIZ;
size += BUFSIZ; size += BUFSIZ;
buf = objc_realloc(buf, size); buf = realloc(buf, size);
if (buf == 0) if (buf == 0)
{ {
GSPrintf(stderr, GSPrintf(stderr,
@ -667,14 +667,14 @@ main(int argc, char** argv, char **env)
int size = BUFSIZ; int size = BUFSIZ;
int got; int got;
int off = 0; int off = 0;
char *buf = objc_malloc(size); char *buf = malloc(size);
char *ptr; char *ptr;
while ((got = fread(buf + off, 1, BUFSIZ, stdin)) == BUFSIZ) while ((got = fread(buf + off, 1, BUFSIZ, stdin)) == BUFSIZ)
{ {
off += BUFSIZ; off += BUFSIZ;
size += BUFSIZ; size += BUFSIZ;
buf = objc_realloc(buf, size); buf = realloc(buf, size);
if (buf == 0) if (buf == 0)
{ {
GSPrintf(stderr, GSPrintf(stderr,