| 51 | } |
| 52 | |
| 53 | static void *ap_json_realloc(void *context, void *ptr, size_t old_size, size_t size) { |
| 54 | ap_json_budget *budget = context; |
| 55 | size_t growth = size > old_size ? size - old_size : 0; |
| 56 | if (growth > AP_JSON_BUDGET - budget->allocated) { |
| 57 | budget->failed = true; |
| 58 | return NULL; |
| 59 | } |
| 60 | void *p = cbm_realloc(CBM_MEM_CLASS_OTHER, ptr, size); |
| 61 | if (p) |
| 62 | budget->allocated += growth; |
| 63 | else |
| 64 | budget->failed = true; |
| 65 | return p; |
| 66 | } |
| 67 | |
| 68 | static void ap_json_free(void *context, void *ptr) { |
| 69 | (void)context; |
nothing calls this directly
no test coverage detected