while (vp) {
np = *vp;
- free(vp);
+ objc_free(vp);
vp = np;
}
objc_mutex_lock(__objc_runtime_mutex);
if (__objc_runtime_threads_alive == 1) {
- free(vp);
+ objc_free(vp);
if (first_free_data)
sarray_remove_garbage();
}
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. */
/* 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. */
/* 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;
/* 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. */
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;
#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;
/* 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) */
#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;
#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;
_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. */
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. */
}
_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. */
usfreelock(mutex->lock, __objc_shared_arena_handle); /* Free IRIX lock. */
- free(mutex); /* Free memory. */
+ objc_free(mutex); /* Free memory. */
return depth; /* Return last depth. */
}
_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. */
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. */
}
_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) {
DosCloseMutexSem (mutex->handle);
- free(mutex); /* Free memory. */
+ objc_free(mutex); /* Free memory. */
return depth; /* Return last depth. */
}
_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. */
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. */
}
{
_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;
}
/* Destroy PCThread mutex */
pthread_mutex_destroy(&(mutex->mutex));
- free(mutex); /* Free memory. */
+ objc_free(mutex); /* Free memory. */
return depth; /* Return last depth. */
}
{
_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. */
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. */
}
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. */
mutex_destroy(&mutex->lock); /* System deallocate. */
- free(mutex); /* Free memory. */
+ objc_free(mutex); /* Free memory. */
return depth; /* Return last depth. */
}
_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. */
CloseHandle(mutex->handle); /* Close Win32 handle. */
- free(mutex); /* Free memory. */
+ objc_free(mutex); /* Free memory. */
return depth; /* Return last depth. */
}
id object = istate->object;
id argument = istate->argument;
- free(istate);
+ objc_free(istate);
/* Clear out the thread local storage */
objc_thread_set_data(NULL);
_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 */
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;
}