void allocRealloc(bool bFree) { int* temp = (int*)malloc(17); int* old_leaked_memory = (int*)realloc(temp, 23); int* leaked_memory = (int*)_recalloc(old_leaked_memory, 1, 31); int* old_leaked_memory_dbg = (int*)malloc(9); int* leaked_memory_dbg = (int*)_realloc_dbg(old_leaked_memory_dbg, 21, _NORMAL_BLOCK, __FILE__, __LINE__); if (bFree) { free(leaked_memory); _free_dbg(leaked_memory_dbg, _NORMAL_BLOCK); } }
/** * Helper for adding another entry to a wstring array. Arg is a * pointer to the actual array pointer so that we can return a pointer * to the last writable entry in the array, and still be able to change * the address the array is pointing to, in case the memory block has to * be moved to resize. */ static inline wchar_t* waadd(wchar_t*** aptr, wchar_t* entry) { size_t szcount = -1; wchar_t *result = NULL; wchar_t **ptr; if(!aptr || !(ptr = *aptr)) fatal(1, L"NULL pointer passed to waadd"); while(ptr[++szcount] != NULL); ptr[szcount] = _wcsdup(entry); result = ptr[szcount++]; if(!(*aptr = (wchar_t**)_recalloc((void*)ptr, szcount, sizeof(wchar_t*)))) { fatal_api_call(L"waadd"); } ptr = *aptr; ptr[szcount] = NULL; return result; }
_CRTIMP void * __cdecl _recalloc_crt(void *ptr, size_t count, size_t size) { unsigned long WaitTime = 0; void *pv; Retry: pv = _recalloc(ptr, count, size); if (!pv && size && _maxwait > 0) { WaitTime = wait_a_bit(WaitTime); if (WaitTime != -1) { goto Retry; } } return pv; }