void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint) { CFAllocatorAllocateCallBack allocateFunc; CFAllocatorReallocateCallBack reallocateFunc; CFAllocatorDeallocateCallBack deallocateFunc; void *newptr; if (NULL == allocator) { allocator = __CFGetDefaultAllocator(); } #if defined(DEBUG) && (DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI) if (allocator->_base._cfisa == __CFISAForCFAllocator()) { __CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator); } #else __CFGenericValidateType(allocator, _kCFRuntimeIDCFAllocator); #endif if (NULL == ptr && 0 < newsize) { #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t * return malloc_zone_malloc((malloc_zone_t *)allocator, newsize); } #endif newptr = NULL; allocateFunc = __CFAllocatorGetAllocateFunction(&allocator->_context); if (allocateFunc) { newptr = (void *)INVOKE_CALLBACK3(allocateFunc, newsize, hint, allocator->_context.info); } return newptr; } if (NULL != ptr && 0 == newsize) { #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t * #if defined(DEBUG) size_t size = malloc_size(ptr); if (size) memset(ptr, 0xCC, size); #endif malloc_zone_free((malloc_zone_t *)allocator, ptr); return NULL; } #endif deallocateFunc = __CFAllocatorGetDeallocateFunction(&allocator->_context); if (NULL != deallocateFunc) { INVOKE_CALLBACK2(deallocateFunc, ptr, allocator->_context.info); } return NULL; } if (NULL == ptr && 0 == newsize) return NULL; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI if (allocator->_base._cfisa != __CFISAForCFAllocator()) { // malloc_zone_t * return malloc_zone_realloc((malloc_zone_t *)allocator, ptr, newsize); } #endif reallocateFunc = __CFAllocatorGetReallocateFunction(&allocator->_context); if (NULL == reallocateFunc) return NULL; newptr = (void *)INVOKE_CALLBACK4(reallocateFunc, ptr, newsize, hint, allocator->_context.info); return newptr; }
void * ruby_xrealloc(void *ptr, size_t size) { if (ptr == NULL) { return ruby_xmalloc(size); } if (size == 0) { size = 1; } void *mem = malloc_zone_realloc(__auto_zone, ptr, size); if (mem == NULL) { rb_memerror(); } return mem; }
void * unexec_realloc (void *old_ptr, size_t new_size) { if (in_dumped_exec) { void *p; if (ptr_in_unexec_regions (old_ptr)) { size_t old_size = ((unexec_malloc_header_t *) old_ptr)[-1].u.size; size_t size = new_size > old_size ? old_size : new_size; p = malloc (new_size); if (size) memcpy (p, old_ptr, size); } else { p = realloc (old_ptr, new_size); } #if MACOSX_MALLOC_MULT16 assert (((vm_address_t) p % 16) == 0); #endif return p; } else { unexec_malloc_header_t *ptr; ptr = (unexec_malloc_header_t *) malloc_zone_realloc (emacs_zone, (unexec_malloc_header_t *) old_ptr - 1, new_size + sizeof (unexec_malloc_header_t)); ptr->u.size = new_size; ptr++; #if MACOSX_MALLOC_MULT16 assert (((vm_address_t) ptr % 16) == 8); #endif return (void *) ptr; } }
void * ruby_xrealloc(void *ptr, size_t size) { void *mem; if (size < 0) { rb_raise(rb_eArgError, "negative re-allocation size"); } if (ptr == NULL) { return ruby_xmalloc(size); } if (size == 0) { size = 1; } #if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 { size_t old_size = malloc_size(ptr); if (old_size >= size) { return ptr; } mem = ruby_xmalloc(size); if (mem == NULL) { rb_memerror(); } auto_zone_write_barrier_memmove(__auto_zone, mem, ptr, old_size); xfree(ptr); } #else mem = malloc_zone_realloc(__auto_zone, ptr, size); if (mem == NULL) { rb_memerror(); } #endif return mem; }
void * ruby_xrealloc(void *ptr, size_t size) { if ((ssize_t)size < 0) { negative_size_allocation_error("negative re-allocation size"); } if (ptr == NULL) { return ruby_xmalloc(size); } if (size == 0) { size = 1; } if (stress_gc && !dont_gc) { garbage_collect(); } void *mem = malloc_zone_realloc(__auto_zone, ptr, size); if (mem == NULL) { rb_memerror(); } return mem; }
static void *__CFAllocatorSystemReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) { return malloc_zone_realloc(info, ptr, newsize); }
void* FMacMallocZone::Realloc( void* Ptr, SIZE_T NewSize, uint32 Alignment ) { check( MemoryZone ); void* Result = malloc_zone_realloc( MemoryZone, Ptr, NewSize ); return Result; }
void *CFAllocatorReallocate(CFAllocatorRef allocator, void *ptr, CFIndex newsize, CFOptionFlags hint) { CFAllocatorAllocateCallBack allocateFunc; CFAllocatorReallocateCallBack reallocateFunc; CFAllocatorDeallocateCallBack deallocateFunc; void *newptr; if (kCFAllocatorSystemDefaultGCRefZero == allocator) { allocator = kCFAllocatorSystemDefault; } else if (kCFAllocatorDefaultGCRefZero == allocator) { // Under GC, we can't use just any old allocator when the GCRefZero allocator was requested allocator = kCFUseCollectableAllocator ? kCFAllocatorSystemDefault : __CFGetDefaultAllocator(); } else if (NULL == allocator) { allocator = __CFGetDefaultAllocator(); } #if defined(DEBUG) && (DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI) if (allocator->_base._cfisa == __CFISAForTypeID(__kCFAllocatorTypeID)) { __CFGenericValidateType(allocator, __kCFAllocatorTypeID); } #else __CFGenericValidateType(allocator, __kCFAllocatorTypeID); #endif if (NULL == ptr && 0 < newsize) { #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) { // malloc_zone_t * return malloc_zone_malloc((malloc_zone_t *)allocator, newsize); } #endif newptr = NULL; allocateFunc = __CFAllocatorGetAllocateFunction(&allocator->_context); if (allocateFunc) { newptr = (void *)INVOKE_CALLBACK3(allocateFunc, newsize, hint, allocator->_context.info); } return newptr; } if (NULL != ptr && 0 == newsize) { #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) { // malloc_zone_t * #if defined(DEBUG) size_t size = malloc_size(ptr); if (size) memset(ptr, 0xCC, size); #endif malloc_zone_free((malloc_zone_t *)allocator, ptr); return NULL; } #endif deallocateFunc = __CFAllocatorGetDeallocateFunction(&allocator->_context); if (NULL != deallocateFunc) { INVOKE_CALLBACK2(deallocateFunc, ptr, allocator->_context.info); } return NULL; } if (NULL == ptr && 0 == newsize) return NULL; #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI if (allocator->_base._cfisa != __CFISAForTypeID(__kCFAllocatorTypeID)) { // malloc_zone_t * return malloc_zone_realloc((malloc_zone_t *)allocator, ptr, newsize); } #endif reallocateFunc = __CFAllocatorGetReallocateFunction(&allocator->_context); if (NULL == reallocateFunc) return NULL; newptr = (void *)INVOKE_CALLBACK4(reallocateFunc, ptr, newsize, hint, allocator->_context.info); return newptr; }
static void *__CFAllocatorSystemReallocate(void *ptr, CFIndex newsize, CFOptionFlags hint, void *info) { malloc_zone_t * const zone = (info == &__MallocDefaultZoneInfoPlaceholder) ? malloc_default_zone() : (malloc_zone_t *)info; return malloc_zone_realloc(zone, ptr, newsize); }