| 19 | #endif |
| 20 | |
| 21 | static 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 | |
| 41 | char *xstrdup(const char *str) |
| 42 | { |
no test coverage detected