blob: 5f1a07c4b87ba81a3e1ed278b0a21b3673ada8cb [file] [log] [blame]
Ingo Molnar07800602009-04-20 15:00:56 +02001/*
2 * Various trivial helper wrappers around standard functions
3 */
4#include "cache.h"
5
6/*
7 * There's no pack memory to release - but stay close to the Git
8 * version so wrap this away:
9 */
Irina Tirdea1d037ca2012-09-11 01:15:03 +030010static inline void release_pack_memory(size_t size __maybe_unused,
11 int flag __maybe_unused)
Ingo Molnar07800602009-04-20 15:00:56 +020012{
13}
14
Ingo Molnar07800602009-04-20 15:00:56 +020015void *xrealloc(void *ptr, size_t size)
16{
17 void *ret = realloc(ptr, size);
18 if (!ret && !size)
19 ret = realloc(ptr, 1);
20 if (!ret) {
21 release_pack_memory(size, -1);
22 ret = realloc(ptr, size);
23 if (!ret && !size)
24 ret = realloc(ptr, 1);
25 if (!ret)
26 die("Out of memory, realloc failed");
27 }
28 return ret;
29}