void *krealloc(const void *p, size_t new_size, gfp_t flags) { void *ret; if (unlikely(!new_size)) { kfree(p); return ZERO_SIZE_PTR; } ret = __krealloc(p, new_size, flags); if (ret && p != ret) kfree(p); return ret; }
static void* repl___krealloc(const void *p, size_t size, gfp_t flags) { void *ret_val; ret_val = __krealloc(p, size, flags); if (size == 0) /* do nothing */ return ret_val; if (p == NULL) { /* same as kmalloc */ if (ret_val != NULL) klc_add_alloc(ret_val, size, stack_depth); } else { /* this part is more tricky as __krealloc may or may not call * kmalloc and, in addition, it does not free 'p'. */ if (ret_val != NULL && ret_val != p) /* allocation has been done */ klc_add_alloc(ret_val, size, stack_depth); } return ret_val; }