I want to use git malloc and realloc shells in my code for OOM conditions (out of memory). Here is his code:
void *xmalloc(size_t size) { void *ret = malloc(size); if (!ret && !size) ret = malloc(1); if (!ret) { release_pack_memory(size, -1); ret = malloc(size); if (!ret && !size) ret = malloc(1); if (!ret) die("Out of memory, malloc failed"); } #ifdef XMALLOC_POISON memset(ret, 0xA5, size); #endif return ret; }
but the release_pack_memory function is located in the sha1_file.c header file, and this function has links to functions in other header files in git and I did not want to make so much effort to isolate this function from git codebase. I'm currently looking for an alternative function for the release_pack_memory function, or you can recommend me another alternative. I will be grateful for any help
Git malloc? , ? , , -, "" release_pack_memory?
*, malloc , , ( release_pack_memory), . , ( , , , ).
malloc
release_pack_memory
* , size 0 , malloc(0), , release_pack_memory - .
size
malloc(0)