void *realloc(void *ptr, size_t size) { if (_mallocmock_fail) return NULL; _mallocmock_realloc_size += size; return __libc_realloc(ptr, size); }
static void* realloc_hook_ini(void* ptr, size_t sz, const __malloc_ptr_t caller) { __malloc_hook = NULL; __realloc_hook = NULL; ptmalloc_init(); return __libc_realloc(ptr, sz); }
void *realloc(void *ptr, size_t size) { void *ret; wrap_log("realloc(%p, 0x%x)", ptr, size); ret = __libc_realloc(ptr, size); wrap_log(" = %p\n", ret); return ret; }
void * realloc(void *x, size_t sz) { if (x != 0) { sylvester(x); x = (void *)((char *)x - sizeof(struct header)); } if ((x = __libc_realloc(x, sizeof(struct header) + sz + CAGE)) == 0) return 0; ((struct header *)x)->magic = MAGIC1 ^ sz; ((struct header *)x)->size = sz; memset((char *)x + sizeof(struct header) + sz, TWEETY, CAGE); return ((char *)x + sizeof(struct header)); }
extern "C" void* realloc(void* in, size_t size) { size_t oldsize = (D && in) ? malloc_usable_size(in) : 0; REF; void* out = __libc_realloc(in,size); DEREF; if (D) { D->now_usable.fetchAndAddOrdered(malloc_usable_size(out) - oldsize); /* Overhead is affected only if old size was 0 */ if (!oldsize) D->now_overhead.fetchAndAddOrdered(CHUNK_OVERHEAD); D->updatePeak(); } return out; }
void *realloc (void *mem, size_t n_bytes) { if (mem == NULL) return malloc (n_bytes); else { gpointer real; real = ((char*)mem) - HEADER_SPACE; g_assert (current_allocation >= 0); current_allocation -= GPOINTER_TO_INT (*(void**)real); g_assert (current_allocation >= 0); return record_bytes (__libc_realloc (real, n_bytes + HEADER_SPACE), n_bytes); } }
void* realloc(void* ptr, size_t size) { if( !chpl_mem_inited() ) { void* ret = __libc_realloc(ptr, size); if( DEBUG_REPLACE_MALLOC ) printf("in early realloc %p = system realloc(%p,%#x)\n", ret, ptr, (int) size); track_system_allocated(ret, size, __libc_malloc); return ret; } else { void* ret = NULL; size_t allocated_len = 0; size_t copy_size; if( DEBUG_REPLACE_MALLOC ) printf("in realloc(%p,%#x)\n", ptr, (int) size); // check to see if we're realloc'ing a pointer that was allocated // before the our allocator came up. if( is_system_allocated(ptr, &allocated_len) ) { if( DEBUG_REPLACE_MALLOC ) { printf("in realloc, ptr %p was system allocated to size %#x\n", ptr, (int) allocated_len); } // allocate some new memory on the Chapel heap ret = chpl_malloc(size); // copy the minimum of allocated_len and size // to handle realloc expanding or shrinking the allocation copy_size = allocated_len; if( size < copy_size ) copy_size = size; memcpy(ret, ptr, copy_size); // free the old pointer from the system heap. __libc_free(ptr); return ret; } else { return chpl_realloc(ptr, size); } } }
void * fail_prone_realloc(void *ptr, size_t size) { return drand48() < ALLOC_ERR_PROB ? NULL : __libc_realloc(ptr, size); }
void * fail_countdown_realloc(void *ptr, size_t size) { if (ALLOC_FAIL_COUNTER >= 0) ALLOC_FAIL_COUNTER--; return ALLOC_FAIL_COUNTER < 0 ? NULL : __libc_realloc(ptr, size); }
void *realloc(void *ptr, size_t size) { return __libc_realloc(ptr, size); }