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

Function slab_acquire

malloc2/malloc2.c:104–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104static void *slab_acquire(struct hc_malloc *a, const size_t size) {
105 struct hc_slab_alloc *sa = hc_baseof(a, struct hc_slab_alloc, malloc);
106 struct slab *s = get_slab(sa, size);
107 uint8_t *p = hc_align(s->next, size);
108 s->next = p + size;
109
110 while (s->slabs.next != &s->slabs) {
111 struct slab *ns = hc_baseof(s->slabs.next, struct slab, slabs);
112
113 if (ns->next - ns->memory > s->next - s->memory) {
114 hc_list_shift_back(&s->slabs);
115 } else {
116 break;
117 }
118 }
119
120 return p;
121}
122
123static void slab_release(struct hc_malloc *a, void *p) {
124 // Do nothing

Callers

nothing calls this directly

Calls 2

get_slabFunction · 0.85
hc_list_shift_backFunction · 0.85

Tested by

no test coverage detected