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

Function get_slab

malloc2/malloc2.c:83–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static struct slab *get_slab(struct hc_slab_alloc *a, const size_t size) {
84 if (size > a->slab_size) {
85 return add_slab(a, size);
86 }
87
88 struct slab *result = NULL;
89
90 hc_list_do(&a->slabs, sl) {
91 struct slab *s = hc_baseof(sl, struct slab, slabs);
92 uint8_t *p = hc_align(s->next, size);
93
94 if (p + size > s->memory + a->slab_size) {
95 break;
96 }
97
98 result = s;
99 }
100
101 return result ? result : add_slab(a, a->slab_size);
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);

Callers 1

slab_acquireFunction · 0.85

Calls 1

add_slabFunction · 0.85

Tested by

no test coverage detected