| 87 | } |
| 88 | |
| 89 | static void * json_alloc (json_state * state, unsigned long size, int zero) |
| 90 | { |
| 91 | if ((state->ulong_max - state->used_memory) < size) |
| 92 | return 0; |
| 93 | |
| 94 | if (state->settings.max_memory |
| 95 | && (state->used_memory += size) > state->settings.max_memory) |
| 96 | { |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | return state->settings.mem_alloc (size, zero, state->settings.user_data); |
| 101 | } |
| 102 | |
| 103 | static int new_value |
| 104 | (json_state * state, json_value ** top, json_value ** root, json_value ** alloc, json_type type) |