MCPcopy Create free account
hub / github.com/git/git / memory_limit_check

Function memory_limit_check

wrapper.c:21–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#endif
20
21static int memory_limit_check(size_t size, int gentle)
22{
23 static size_t limit = 0;
24 if (!limit) {
25 limit = git_env_ulong("GIT_ALLOC_LIMIT", 0);
26 if (!limit)
27 limit = SIZE_MAX;
28 }
29 if (size > limit) {
30 if (gentle) {
31 error("attempting to allocate %"PRIuMAX" over limit %"PRIuMAX,
32 (uintmax_t)size, (uintmax_t)limit);
33 return -1;
34 } else
35 die("attempting to allocate %"PRIuMAX" over limit %"PRIuMAX,
36 (uintmax_t)size, (uintmax_t)limit);
37 }
38 return 0;
39}
40
41char *xstrdup(const char *str)
42{

Callers 3

do_xmallocFunction · 0.85
xreallocFunction · 0.85
xcallocFunction · 0.85

Calls 3

git_env_ulongFunction · 0.85
errorFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected