MCPcopy Create free account
hub / github.com/codr7/hacktical-c / memo_acquire

Function memo_acquire

malloc2/malloc2.c:14–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12};
13
14static 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
34static void memo_release(struct hc_malloc *a, void *p) {
35 struct hc_memo_alloc *ma = hc_baseof(a, struct hc_memo_alloc, malloc);

Callers

nothing calls this directly

Calls 4

hc_set_lengthFunction · 0.85
hc_set_indexFunction · 0.85
hc_vector_getFunction · 0.85
hc_vector_deleteFunction · 0.85

Tested by

no test coverage detected