| 12 | }; |
| 13 | |
| 14 | static void *memo_acquire(struct hc_malloc *a, size_t size) { |
| 15 | struct hc_memo_alloc *ma = hc_baseof(a, struct hc_memo_alloc, malloc); |
| 16 | |
| 17 | if (hc_set_length(&ma->memo)) { |
| 18 | bool ok = false; |
| 19 | size_t i = hc_set_index(&ma->memo, &size, &ok); |
| 20 | |
| 21 | if (ok) { |
| 22 | struct hc_vector *is = &ma->memo.items; |
| 23 | struct memo *m = *(struct memo **)hc_vector_get(is, i); |
| 24 | hc_vector_delete(is, i, 1); |
| 25 | return m->data; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | struct memo *m = hc_acquire(ma->source, sizeof(struct memo) + size); |
| 30 | m->size = size; |
| 31 | return m->data; |
| 32 | } |
| 33 | |
| 34 | static void memo_release(struct hc_malloc *a, void *p) { |
| 35 | struct hc_memo_alloc *ma = hc_baseof(a, struct hc_memo_alloc, malloc); |
nothing calls this directly
no test coverage detected