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

Function bump_acquire

malloc1/malloc1.c:22–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20/* Bump */
21
22static void *bump_acquire(struct hc_malloc *a, size_t size) {
23 if (size <= 0) {
24 hc_throw(HC_INVALID_SIZE);
25 }
26
27 struct hc_bump_alloc *ba = hc_baseof(a, struct hc_bump_alloc, malloc);
28
29 if (ba->size - ba->offset < size) {
30 hc_throw(HC_NO_MEMORY);
31 }
32
33 uint8_t *p = ba->memory + ba->offset;
34 uint8_t *pa = hc_align(p, size);
35 ba->offset = ba->offset + pa - p + size;
36 return pa;
37}
38
39static void bump_release(struct hc_malloc *a, void *p) {
40 //Do nothing

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected