Replace use of __objc_xmalloc and free with objc_malloc and objc_free.
From-SVN: r12768
This commit is contained in:
parent
df7fbc8cd8
commit
039f5fb1a8
|
@ -63,7 +63,7 @@ sarray_remove_garbage(void)
|
|||
|
||||
while (vp) {
|
||||
np = *vp;
|
||||
free(vp);
|
||||
objc_free(vp);
|
||||
vp = np;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ sarray_free_garbage(void *vp)
|
|||
objc_mutex_lock(__objc_runtime_mutex);
|
||||
|
||||
if (__objc_runtime_threads_alive == 1) {
|
||||
free(vp);
|
||||
objc_free(vp);
|
||||
if (first_free_data)
|
||||
sarray_remove_garbage();
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
|
|||
if ((*the_index) == array->empty_index) {
|
||||
|
||||
/* The index was previously empty, allocate a new */
|
||||
new_index = (struct sindex*)__objc_xmalloc(sizeof(struct sindex));
|
||||
new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
|
||||
memcpy(new_index, array->empty_index, sizeof(struct sindex));
|
||||
new_index->version.version = array->version.version;
|
||||
*the_index = new_index; /* Prepared for install. */
|
||||
|
@ -156,7 +156,7 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
|
|||
|
||||
/* This index must be lazy copied */
|
||||
struct sindex* old_index = *the_index;
|
||||
new_index = (struct sindex*)__objc_xmalloc(sizeof(struct sindex));
|
||||
new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
|
||||
memcpy( new_index, old_index, sizeof(struct sindex));
|
||||
new_index->version.version = array->version.version;
|
||||
*the_index = new_index; /* Prepared for install. */
|
||||
|
@ -173,7 +173,7 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
|
|||
|
||||
/* The bucket was previously empty (or something like that), */
|
||||
/* allocate a new. This is the effect of `lazy' allocation */
|
||||
new_bucket = (struct sbucket*)__objc_xmalloc(sizeof(struct sbucket));
|
||||
new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
|
||||
memcpy((void *) new_bucket, (const void*)array->empty_bucket,
|
||||
sizeof(struct sbucket));
|
||||
new_bucket->version.version = array->version.version;
|
||||
|
@ -185,7 +185,7 @@ sarray_at_put(struct sarray* array, sidx index, void* element)
|
|||
|
||||
/* Perform lazy copy. */
|
||||
struct sbucket* old_bucket = *the_bucket;
|
||||
new_bucket = (struct sbucket*)__objc_xmalloc(sizeof(struct sbucket));
|
||||
new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
|
||||
memcpy( new_bucket, old_bucket, sizeof(struct sbucket));
|
||||
new_bucket->version.version = array->version.version;
|
||||
*the_bucket = new_bucket; /* Prepared for install. */
|
||||
|
@ -220,16 +220,16 @@ sarray_new (int size, void* default_element)
|
|||
assert(size > 0);
|
||||
|
||||
/* Allocate core array */
|
||||
arr = (struct sarray*) __objc_xmalloc(sizeof(struct sarray));
|
||||
arr = (struct sarray*) objc_malloc(sizeof(struct sarray));
|
||||
arr->version.version = 0;
|
||||
|
||||
/* Initialize members */
|
||||
#ifdef OBJC_SPARSE3
|
||||
arr->capacity = num_indices*INDEX_CAPACITY;
|
||||
new_indices = (struct sindex**)
|
||||
__objc_xmalloc(sizeof(struct sindex*)*num_indices);
|
||||
objc_malloc(sizeof(struct sindex*)*num_indices);
|
||||
|
||||
arr->empty_index = (struct sindex*) __objc_xmalloc(sizeof(struct sindex));
|
||||
arr->empty_index = (struct sindex*) objc_malloc(sizeof(struct sindex));
|
||||
arr->empty_index->version.version = 0;
|
||||
|
||||
narrays += 1;
|
||||
|
@ -239,14 +239,14 @@ sarray_new (int size, void* default_element)
|
|||
#else /* OBJC_SPARSE2 */
|
||||
arr->capacity = num_indices*BUCKET_SIZE;
|
||||
new_buckets = (struct sbucket**)
|
||||
__objc_xmalloc(sizeof(struct sbucket*)*num_indices);
|
||||
objc_malloc(sizeof(struct sbucket*)*num_indices);
|
||||
|
||||
narrays += 1;
|
||||
idxsize += num_indices;
|
||||
|
||||
#endif
|
||||
|
||||
arr->empty_bucket = (struct sbucket*) __objc_xmalloc(sizeof(struct sbucket));
|
||||
arr->empty_bucket = (struct sbucket*) objc_malloc(sizeof(struct sbucket));
|
||||
arr->empty_bucket->version.version = 0;
|
||||
|
||||
nbuckets += 1;
|
||||
|
@ -337,11 +337,11 @@ sarray_realloc(struct sarray* array, int newsize)
|
|||
/* alloc to force re-read by any concurrent readers. */
|
||||
old_indices = array->indices;
|
||||
new_indices = (struct sindex**)
|
||||
__objc_xmalloc((new_max_index+1)*sizeof(struct sindex*));
|
||||
objc_malloc((new_max_index+1)*sizeof(struct sindex*));
|
||||
#else /* OBJC_SPARSE2 */
|
||||
old_buckets = array->buckets;
|
||||
new_buckets = (struct sbucket**)
|
||||
__objc_xmalloc((new_max_index+1)*sizeof(struct sbucket*));
|
||||
objc_malloc((new_max_index+1)*sizeof(struct sbucket*));
|
||||
#endif
|
||||
|
||||
/* copy buckets below old_max_index (they are still valid) */
|
||||
|
@ -488,7 +488,7 @@ sarray_lazy_copy(struct sarray* oarr)
|
|||
#endif
|
||||
|
||||
/* Allocate core array */
|
||||
arr = (struct sarray*) __objc_xmalloc(sizeof(struct sarray)); /* !!! */
|
||||
arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); /* !!! */
|
||||
arr->version.version = oarr->version.version + 1;
|
||||
#ifdef OBJC_SPARSE3
|
||||
arr->empty_index = oarr->empty_index;
|
||||
|
@ -502,14 +502,14 @@ sarray_lazy_copy(struct sarray* oarr)
|
|||
#ifdef OBJC_SPARSE3
|
||||
/* Copy bucket table */
|
||||
new_indices = (struct sindex**)
|
||||
__objc_xmalloc(sizeof(struct sindex*)*num_indices);
|
||||
objc_malloc(sizeof(struct sindex*)*num_indices);
|
||||
memcpy( new_indices,oarr->indices,
|
||||
sizeof(struct sindex*)*num_indices);
|
||||
arr->indices = new_indices;
|
||||
#else
|
||||
/* Copy bucket table */
|
||||
new_buckets = (struct sbucket**)
|
||||
__objc_xmalloc(sizeof(struct sbucket*)*num_indices);
|
||||
objc_malloc(sizeof(struct sbucket*)*num_indices);
|
||||
memcpy( new_buckets,oarr->buckets,
|
||||
sizeof(struct sbucket*)*num_indices);
|
||||
arr->buckets = new_buckets;
|
||||
|
|
|
@ -211,13 +211,13 @@ objc_mutex_allocate(void)
|
|||
_objc_mutex_t mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
err = pthread_mutex_init(&mutex->lock, pthread_mutexattr_default);
|
||||
|
||||
if (err != 0) { /* System init failed? */
|
||||
free(mutex); /* Yes, free local memory. */
|
||||
objc_free(mutex); /* Yes, free local memory. */
|
||||
return NULL; /* Abort. */
|
||||
}
|
||||
mutex->owner = (_objc_thread_t) -1; /* No owner. */
|
||||
|
@ -244,7 +244,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
pthread_mutex_unlock(&mutex->lock); /* Must unlock system mutex.*/
|
||||
pthread_mutex_destroy(&mutex->lock); /* Free system mutex. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -191,14 +191,14 @@ objc_mutex_allocate(void)
|
|||
_objc_mutex_t mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
if (!(mutex->lock = usnewlock(__objc_shared_arena_handle)))
|
||||
err = -1;
|
||||
|
||||
if (err != 0) { /* System init failed? */
|
||||
free(mutex); /* Yes, free local memory. */
|
||||
objc_free(mutex); /* Yes, free local memory. */
|
||||
return NULL; /* Abort. */
|
||||
}
|
||||
mutex->owner = NULL; /* No owner. */
|
||||
|
@ -224,7 +224,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
|
||||
usfreelock(mutex->lock, __objc_shared_arena_handle); /* Free IRIX lock. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -250,13 +250,13 @@ objc_mutex_allocate(void)
|
|||
_objc_mutex_t mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
err = mutex_init(&(mutex->lock));
|
||||
|
||||
if (err != 0) { /* System init failed? */
|
||||
free(mutex); /* Yes, free local memory. */
|
||||
objc_free(mutex); /* Yes, free local memory. */
|
||||
return NULL; /* Abort. */
|
||||
}
|
||||
mutex->owner = (_objc_thread_t) -1; /* No owner. */
|
||||
|
@ -283,7 +283,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
mutex_unlock(&(mutex->lock)); /* Must unlock system mutex.*/
|
||||
mutex_clear(&(mutex->lock)); /* Free system mutex. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ objc_mutex_allocate(void)
|
|||
_objc_mutex_t mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
if (DosCreateMutexSem (NULL,&(mutex->handle),0L,0) > 0) {
|
||||
|
@ -259,7 +259,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
|
||||
DosCloseMutexSem (mutex->handle);
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -209,13 +209,13 @@ objc_mutex_allocate(void)
|
|||
_objc_mutex_t mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
err = pthread_mutex_init(&mutex->lock, NULL);
|
||||
|
||||
if (err != 0) { /* System init failed? */
|
||||
free(mutex); /* Yes, free local memory. */
|
||||
objc_free(mutex); /* Yes, free local memory. */
|
||||
return NULL; /* Abort. */
|
||||
}
|
||||
mutex->owner = NULL; /* No owner. */
|
||||
|
@ -242,7 +242,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
pthread_mutex_unlock(&mutex->lock); /* Must unlock system mutex.*/
|
||||
pthread_mutex_destroy(&mutex->lock); /* Free system mutex. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -183,14 +183,14 @@ objc_mutex_allocate(void)
|
|||
{
|
||||
_objc_mutex_t mutex;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
/* Create PCThread mutex */
|
||||
if ( pthread_mutex_init(&(mutex->mutex), NULL) )
|
||||
{
|
||||
/* Failed */
|
||||
free(mutex);
|
||||
objc_free(mutex);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
/* Destroy PCThread mutex */
|
||||
pthread_mutex_destroy(&(mutex->mutex));
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ objc_mutex_allocate(void)
|
|||
{
|
||||
_objc_mutex_t mutex;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
mutex->owner = NULL; /* No owner. */
|
||||
|
@ -166,7 +166,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
return -1; /* Yes, abort. */
|
||||
depth = objc_mutex_lock(mutex); /* Must have lock. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -213,13 +213,13 @@ objc_mutex_allocate(void)
|
|||
struct _objc_mutex *mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
err = mutex_init(&mutex->lock, USYNC_THREAD, 0);
|
||||
|
||||
if (err != 0) { /* System init failed? */
|
||||
free(mutex); /* Yes, free local memory. */
|
||||
objc_free(mutex); /* Yes, free local memory. */
|
||||
return NULL; /* Abort. */
|
||||
}
|
||||
mutex->owner = NULL; /* No owner. */
|
||||
|
@ -245,7 +245,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
|
||||
mutex_destroy(&mutex->lock); /* System deallocate. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -220,11 +220,11 @@ objc_mutex_allocate(void)
|
|||
_objc_mutex_t mutex;
|
||||
int err = 0;
|
||||
|
||||
if (!(mutex = (_objc_mutex_t)__objc_xmalloc(sizeof(struct _objc_mutex))))
|
||||
if (!(mutex = (_objc_mutex_t) objc_malloc(sizeof(struct _objc_mutex))))
|
||||
return NULL; /* Abort if malloc failed. */
|
||||
|
||||
if ((mutex->handle = CreateMutex(NULL, 0, NULL)) == NULL) {
|
||||
free(mutex); /* Failed, free memory. */
|
||||
objc_free(mutex); /* Failed, free memory. */
|
||||
return NULL; /* Abort. */
|
||||
}
|
||||
mutex->owner = NULL; /* No owner. */
|
||||
|
@ -250,7 +250,7 @@ objc_mutex_deallocate(_objc_mutex_t mutex)
|
|||
|
||||
CloseHandle(mutex->handle); /* Close Win32 handle. */
|
||||
|
||||
free(mutex); /* Free memory. */
|
||||
objc_free(mutex); /* Free memory. */
|
||||
return depth; /* Return last depth. */
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ __objc_thread_detach_function(struct __objc_thread_start_state *istate)
|
|||
id object = istate->object;
|
||||
id argument = istate->argument;
|
||||
|
||||
free(istate);
|
||||
objc_free(istate);
|
||||
|
||||
/* Clear out the thread local storage */
|
||||
objc_thread_set_data(NULL);
|
||||
|
@ -117,7 +117,7 @@ objc_thread_detach(SEL selector, id object, id argument)
|
|||
_objc_thread_t thread_id = NULL; /* Detached thread id. */
|
||||
|
||||
if (!(istate = (struct __objc_thread_start_state *)
|
||||
__objc_xmalloc(sizeof(*istate)))) /* Can we allocate state? */
|
||||
objc_malloc(sizeof(*istate)))) /* Can we allocate state? */
|
||||
return NULL; /* No, abort. */
|
||||
|
||||
istate->selector = selector; /* Initialize the thread's */
|
||||
|
@ -126,7 +126,7 @@ objc_thread_detach(SEL selector, id object, id argument)
|
|||
|
||||
if ((thread_id = objc_thread_create((void *)__objc_thread_detach_function,
|
||||
istate)) == NULL) {
|
||||
free(istate); /* Release state if failed. */
|
||||
objc_free(istate); /* Release state if failed. */
|
||||
return thread_id;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue