MCPcopy Index your code
hub / github.com/git/git / do_xmalloc

Function do_xmalloc

wrapper.c:49–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49static void *do_xmalloc(size_t size, int gentle)
50{
51 void *ret;
52
53 if (memory_limit_check(size, gentle))
54 return NULL;
55 ret = malloc(size);
56 if (!ret && !size)
57 ret = malloc(1);
58 if (!ret) {
59 if (!gentle)
60 die("Out of memory, malloc failed (tried to allocate %lu bytes)",
61 (unsigned long)size);
62 else {
63 error("Out of memory, malloc failed (tried to allocate %lu bytes)",
64 (unsigned long)size);
65 return NULL;
66 }
67 }
68#ifdef XMALLOC_POISON
69 memset(ret, 0xA5, size);
70#endif
71 return ret;
72}
73
74void *xmalloc(size_t size)
75{

Callers 2

xmallocFunction · 0.85
do_xmalloczFunction · 0.85

Calls 3

memory_limit_checkFunction · 0.85
errorFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected