linux-kernel-test/tools/perf/util/wrapper.c
Arnaldo Carvalho de Melo cf47a8aede perf tools: Remove unused perf_pathdup, xstrdup functions
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-s87zi5d03m6rz622y1z6rlsa@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-03-23 15:27:33 -03:00

30 lines
609 B
C

/*
* Various trivial helper wrappers around standard functions
*/
#include "cache.h"
/*
* There's no pack memory to release - but stay close to the Git
* version so wrap this away:
*/
static inline void release_pack_memory(size_t size __maybe_unused,
int flag __maybe_unused)
{
}
void *xrealloc(void *ptr, size_t size)
{
void *ret = realloc(ptr, size);
if (!ret && !size)
ret = realloc(ptr, 1);
if (!ret) {
release_pack_memory(size, -1);
ret = realloc(ptr, size);
if (!ret && !size)
ret = realloc(ptr, 1);
if (!ret)
die("Out of memory, realloc failed");
}
return ret;
}