Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
rmem.h
Go to the documentation of this file.
1
41#ifndef RMEM_H
42#define RMEM_H
43
44#include <inttypes.h>
45#include <stdbool.h>
46
47//----------------------------------------------------------------------------------
48// Defines and Macros
49//----------------------------------------------------------------------------------
50#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
51 #define RMEMAPI __declspec(dllexport) // We are building library as a Win32 shared library (.dll)
52#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
53 #define RMEMAPI __declspec(dllimport) // We are using library as a Win32 shared library (.dll)
54#else
55 #define RMEMAPI // We are building or using library as a static library (or Linux shared library)
56#endif
57
58#define RMEM_VERSION "v1.3" // changelog at bottom of header.
59
60//----------------------------------------------------------------------------------
61// Types and Structures Definition
62//----------------------------------------------------------------------------------
63
64// Memory Pool
65typedef struct MemNode MemNode;
66struct MemNode {
67 size_t size;
69};
70
71// Freelist implementation
72typedef struct AllocList {
74 size_t len;
76
77// Arena allocator.
78typedef struct Arena {
80 size_t size;
82
83
84enum {
86 MEMPOOL_BUCKET_BITS = (sizeof(uintptr_t) >> 1) + 1,
87 MEM_SPLIT_THRESHOLD = sizeof(uintptr_t) * 4
88};
89
90typedef struct MemPool {
94
95
96// Object Pool
97typedef struct ObjPool {
101
102
103// Double-Ended Stack aka Deque
104typedef struct BiStack {
106 size_t size;
108
109
110#if defined(__cplusplus)
111extern "C" { // Prevents name mangling of functions
112#endif
113
114//------------------------------------------------------------------------------------
115// Functions Declaration - Memory Pool
116//------------------------------------------------------------------------------------
118RMEMAPI MemPool CreateMemPoolFromBuffer(void *buf, size_t bytes);
120
121RMEMAPI void *MemPoolAlloc(MemPool *mempool, size_t bytes);
122RMEMAPI void *MemPoolRealloc(MemPool *mempool, void *ptr, size_t bytes);
123RMEMAPI void MemPoolFree(MemPool *mempool, void *ptr);
124RMEMAPI void MemPoolCleanUp(MemPool *mempool, void **ptrref);
127
128//------------------------------------------------------------------------------------
129// Functions Declaration - Object Pool
130//------------------------------------------------------------------------------------
131RMEMAPI ObjPool CreateObjPool(size_t objsize, size_t len);
132RMEMAPI ObjPool CreateObjPoolFromBuffer(void *buf, size_t objsize, size_t len);
134
136RMEMAPI void ObjPoolFree(ObjPool *objpool, void *ptr);
137RMEMAPI void ObjPoolCleanUp(ObjPool *objpool, void **ptrref);
138
139//------------------------------------------------------------------------------------
140// Functions Declaration - Double-Ended Stack
141//------------------------------------------------------------------------------------
145
146RMEMAPI void *BiStackAllocFront(BiStack *destack, size_t len);
147RMEMAPI void *BiStackAllocBack(BiStack *destack, size_t len);
148
152
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif // RMEM_H
160
161
167#if defined(RMEM_IMPLEMENTATION)
168
169#include <stdio.h> // Required for:
170#include <stdlib.h> // Required for:
171#include <string.h> // Required for:
172
173//----------------------------------------------------------------------------------
174// Defines and Macros
175//----------------------------------------------------------------------------------
176
177// Make sure restrict type qualifier for pointers is defined
178// NOTE: Not supported by C++, it is a C only keyword
179#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) || defined(_MSC_VER)
180 #ifndef restrict
181 #define restrict __restrict
182 #endif
183#endif
184
185//----------------------------------------------------------------------------------
186// Global Variables Definition
187//----------------------------------------------------------------------------------
188// ...
189
190//----------------------------------------------------------------------------------
191// Module specific Functions Declaration
192//----------------------------------------------------------------------------------
193static inline size_t __AlignSize(const size_t size, const size_t align)
194{
195 return (size + (align - 1)) & -align;
196}
197
198static MemNode *__SplitMemNode(MemNode *const node, const size_t bytes)
199{
200 uintptr_t n = ( uintptr_t )node;
201 MemNode *const r = ( MemNode* )(n + (node->size - bytes));
202 node->size -= bytes;
203 r->size = bytes;
204 return r;
205}
206
207static void __InsertMemNodeBefore(AllocList *const list, MemNode *const insert, MemNode *const curr)
208{
209 insert->next = curr;
210 if (curr->prev==NULL) list->head = insert;
211 else
212 {
213 insert->prev = curr->prev;
214 curr->prev->next = insert;
215 }
216 curr->prev = insert;
217}
218
219static void __ReplaceMemNode(MemNode *const old, MemNode *const replace)
220{
221 replace->prev = old->prev;
222 replace->next = old->next;
223 if( old->prev != NULL )
224 old->prev->next = replace;
225 if( old->next != NULL )
226 old->next->prev = replace;
227}
228
229
230static MemNode *__RemoveMemNode(AllocList *const list, MemNode *const node)
231{
232 if (node->prev != NULL) node->prev->next = node->next;
233 else
234 {
235 list->head = node->next;
236 if (list->head != NULL) list->head->prev = NULL;
237 else list->tail = NULL;
238 }
239
240 if (node->next != NULL) node->next->prev = node->prev;
241 else
242 {
243 list->tail = node->prev;
244 if (list->tail != NULL) list->tail->next = NULL;
245 else list->head = NULL;
246 }
247 list->len--;
248 return node;
249}
250
251static MemNode *__FindMemNode(AllocList *const list, const size_t bytes)
252{
253 for (MemNode *node = list->head; node != NULL; node = node->next)
254 {
255 if (node->size < bytes) continue;
256 // close in size - reduce fragmentation by not splitting.
257 else if (node->size <= bytes + MEM_SPLIT_THRESHOLD) return __RemoveMemNode(list, node);
258 else return __SplitMemNode(node, bytes);
259 }
260 return NULL;
261}
262
263static void __InsertMemNode(MemPool *const mempool, AllocList *const list, MemNode *const node, const bool is_bucket)
264{
265 if (list->head == NULL)
266 {
267 list->head = node;
268 list->len++;
269 }
270 else
271 {
272 for (MemNode *iter = list->head; iter != NULL; iter = iter->next)
273 {
274 if (( uintptr_t )iter == mempool->arena.offs)
275 {
276 mempool->arena.offs += iter->size;
277 __RemoveMemNode(list, iter);
278 iter = list->head;
279 if (iter == NULL) {
280 list->head = node;
281 return;
282 }
283 }
284 const uintptr_t inode = ( uintptr_t )node;
285 const uintptr_t iiter = ( uintptr_t )iter;
286 const uintptr_t iter_end = iiter + iter->size;
287 const uintptr_t node_end = inode + node->size;
288 if (iter==node) return;
289 else if (iter < node)
290 {
291 // node was coalesced prior.
292 if (iter_end > inode) return;
293 else if (iter_end==inode && !is_bucket)
294 {
295 // if we can coalesce, do so.
296 iter->size += node->size;
297 return;
298 }
299 else if (iter->next == NULL)
300 {
301 // we reached the end of the free list -> append the node
302 iter->next = node;
303 node->prev = iter;
304 list->len++;
305 return;
306 }
307 }
308 else if (iter > node)
309 {
310 // Address sort, lowest to highest aka ascending order.
311 if (iiter < node_end) return;
312 else if (iter==list->head && !is_bucket)
313 {
314 if (iter_end==inode) iter->size += node->size;
315 else if (node_end==iiter)
316 {
317 node->size += list->head->size;
318 node->next = list->head->next;
319 node->prev = NULL;
320 list->head = node;
321 }
322 else
323 {
324 node->next = iter;
325 node->prev = NULL;
326 iter->prev = node;
327 list->head = node;
328 list->len++;
329 }
330 return;
331 }
332 else if (iter_end==inode && !is_bucket)
333 {
334 // if we can coalesce, do so.
335 iter->size += node->size;
336 return;
337 }
338 else
339 {
340 __InsertMemNodeBefore(list, node, iter);
341 list->len++;
342 return;
343 }
344 }
345 }
346 }
347}
348
349//----------------------------------------------------------------------------------
350// Module Functions Definition - Memory Pool
351//----------------------------------------------------------------------------------
352
353MemPool CreateMemPool(const size_t size)
354{
355 MemPool mempool = { 0 };
356
357 if (size == 0) return mempool;
358 else
359 {
360 // Align the mempool size to at least the size of an alloc node.
361 uint8_t *const restrict buf = malloc(size*sizeof *buf);
362 if (buf==NULL) return mempool;
363 else
364 {
365 mempool.arena.size = size;
366 mempool.arena.mem = ( uintptr_t )buf;
367 mempool.arena.offs = mempool.arena.mem + mempool.arena.size;
368 return mempool;
369 }
370 }
371}
372
373MemPool CreateMemPoolFromBuffer(void *const restrict buf, const size_t size)
374{
375 MemPool mempool = { 0 };
376 if ((size == 0) || (buf == NULL) || (size <= sizeof(MemNode))) return mempool;
377 else
378 {
379 mempool.arena.size = size;
380 mempool.arena.mem = ( uintptr_t )buf;
381 mempool.arena.offs = mempool.arena.mem + mempool.arena.size;
382 return mempool;
383 }
384}
385
386void DestroyMemPool(MemPool *const restrict mempool)
387{
388 if (mempool->arena.mem == 0) return;
389 else
390 {
391 void *const restrict ptr = ( void* )mempool->arena.mem;
392 free(ptr);
393 *mempool = (MemPool){ 0 };
394 }
395}
396
397void *MemPoolAlloc(MemPool *const mempool, const size_t size)
398{
399 if ((size == 0) || (size > mempool->arena.size)) return NULL;
400 else
401 {
402 MemNode *new_mem = NULL;
403 const size_t ALLOC_SIZE = __AlignSize(size + sizeof *new_mem, sizeof(intptr_t));
404 const size_t BUCKET_SLOT = (ALLOC_SIZE >> MEMPOOL_BUCKET_BITS) - 1;
405
406 // If the size is small enough, let's check if our buckets has a fitting memory block.
407 if (BUCKET_SLOT < MEMPOOL_BUCKET_SIZE)
408 {
409 new_mem = __FindMemNode(&mempool->buckets[BUCKET_SLOT], ALLOC_SIZE);
410 }
411 else if (mempool->large.head != NULL)
412 {
413 new_mem = __FindMemNode(&mempool->large, ALLOC_SIZE);
414 }
415
416 if (new_mem == NULL)
417 {
418 // not enough memory to support the size!
419 if ((mempool->arena.offs - ALLOC_SIZE) < mempool->arena.mem) return NULL;
420 else
421 {
422 // Couldn't allocate from a freelist, allocate from available mempool.
423 // Subtract allocation size from the mempool.
424 mempool->arena.offs -= ALLOC_SIZE;
425
426 // Use the available mempool space as the new node.
427 new_mem = ( MemNode* )mempool->arena.offs;
428 new_mem->size = ALLOC_SIZE;
429 }
430 }
431
432 // Visual of the allocation block.
433 // --------------
434 // | mem size | lowest addr of block
435 // | next node | 12 byte (32-bit) header
436 // | prev node | 24 byte (64-bit) header
437 // |------------|
438 // | alloc'd |
439 // | memory |
440 // | space | highest addr of block
441 // --------------
442 new_mem->next = new_mem->prev = NULL;
443 uint8_t *const restrict final_mem = ( uint8_t* )new_mem + sizeof *new_mem;
444 return memset(final_mem, 0, new_mem->size - sizeof *new_mem);
445 }
446}
447
448void *MemPoolRealloc(MemPool *const restrict mempool, void *const ptr, const size_t size)
449{
450 if (size > mempool->arena.size) return NULL;
451 // NULL ptr should make this work like regular Allocation.
452 else if (ptr == NULL) return MemPoolAlloc(mempool, size);
453 else if ((uintptr_t)ptr - sizeof(MemNode) < mempool->arena.mem) return NULL;
454 else
455 {
456 MemNode *const node = ( MemNode* )(( uint8_t* )ptr - sizeof *node);
457 const size_t NODE_SIZE = sizeof *node;
458 uint8_t *const resized_block = MemPoolAlloc(mempool, size);
459 if (resized_block == NULL) return NULL;
460 else
461 {
462 MemNode *const resized = ( MemNode* )(resized_block - sizeof *resized);
463 memmove(resized_block, ptr, (node->size > resized->size)? (resized->size - NODE_SIZE) : (node->size - NODE_SIZE));
464 MemPoolFree(mempool, ptr);
465 return resized_block;
466 }
467 }
468}
469
470void MemPoolFree(MemPool *const restrict mempool, void *const ptr)
471{
472 const uintptr_t p = ( uintptr_t )ptr;
473 if ((ptr == NULL) || (p - sizeof(MemNode) < mempool->arena.mem)) return;
474 else
475 {
476 // Behind the actual pointer data is the allocation info.
477 const uintptr_t block = p - sizeof(MemNode);
478 MemNode *const mem_node = ( MemNode* )block;
479 const size_t BUCKET_SLOT = (mem_node->size >> MEMPOOL_BUCKET_BITS) - 1;
480
481 // Make sure the pointer data is valid.
482 if ((block < mempool->arena.offs) ||
483 ((block - mempool->arena.mem) > mempool->arena.size) ||
484 (mem_node->size == 0) ||
485 (mem_node->size > mempool->arena.size)) return;
486 // If the mem_node is right at the arena offs, then merge it back to the arena.
487 else if (block == mempool->arena.offs)
488 {
489 mempool->arena.offs += mem_node->size;
490 }
491 else
492 {
493 // try to place it into bucket or large freelist.
494 struct AllocList *const l = (BUCKET_SLOT < MEMPOOL_BUCKET_SIZE) ? &mempool->buckets[BUCKET_SLOT] : &mempool->large;
495 __InsertMemNode(mempool, l, mem_node, (BUCKET_SLOT < MEMPOOL_BUCKET_SIZE));
496 }
497 }
498}
499
500void MemPoolCleanUp(MemPool *const restrict mempool, void **const ptrref)
501{
502 if ((ptrref == NULL) || (*ptrref == NULL)) return;
503 else
504 {
505 MemPoolFree(mempool, *ptrref);
506 *ptrref = NULL;
507 }
508}
509
510size_t GetMemPoolFreeMemory(const MemPool mempool)
511{
512 size_t total_remaining = mempool.arena.offs - mempool.arena.mem;
513
514 for (MemNode *n=mempool.large.head; n != NULL; n = n->next) total_remaining += n->size;
515
516 for (size_t i=0; i<MEMPOOL_BUCKET_SIZE; i++) for (MemNode *n = mempool.buckets[i].head; n != NULL; n = n->next) total_remaining += n->size;
517
518 return total_remaining;
519}
520
521void MemPoolReset(MemPool *const mempool)
522{
523 mempool->large.head = mempool->large.tail = NULL;
524 mempool->large.len = 0;
525 for (size_t i = 0; i < MEMPOOL_BUCKET_SIZE; i++)
526 {
527 mempool->buckets[i].head = mempool->buckets[i].tail = NULL;
528 mempool->buckets[i].len = 0;
529 }
530 mempool->arena.offs = mempool->arena.mem + mempool->arena.size;
531}
532
533//----------------------------------------------------------------------------------
534// Module Functions Definition - Object Pool
535//----------------------------------------------------------------------------------
536
537ObjPool CreateObjPool(const size_t objsize, const size_t len)
538{
539 ObjPool objpool = { 0 };
540 if ((len == 0) || (objsize == 0)) return objpool;
541 else
542 {
543 const size_t aligned_size = __AlignSize(objsize, sizeof(size_t));
544 uint8_t *const restrict buf = calloc(len, aligned_size);
545 if (buf == NULL) return objpool;
546 objpool.objSize = aligned_size;
547 objpool.memSize = objpool.freeBlocks = len;
548 objpool.mem = ( uintptr_t )buf;
549
550 for (size_t i=0; i<objpool.freeBlocks; i++)
551 {
552 size_t *const restrict index = ( size_t* )(objpool.mem + (i*aligned_size));
553 *index = i + 1;
554 }
555
556 objpool.offs = objpool.mem;
557 return objpool;
558 }
559}
560
561ObjPool CreateObjPoolFromBuffer(void *const restrict buf, const size_t objsize, const size_t len)
562{
563 ObjPool objpool = { 0 };
564
565 // If the object size isn't large enough to align to a size_t, then we can't use it.
566 const size_t aligned_size = __AlignSize(objsize, sizeof(size_t));
567 if ((buf == NULL) || (len == 0) || (objsize < sizeof(size_t)) || (objsize*len != aligned_size*len)) return objpool;
568 else
569 {
570 objpool.objSize = aligned_size;
571 objpool.memSize = objpool.freeBlocks = len;
572 objpool.mem = (uintptr_t)buf;
573
574 for (size_t i=0; i<objpool.freeBlocks; i++)
575 {
576 size_t *const restrict index = ( size_t* )(objpool.mem + (i*aligned_size));
577 *index = i + 1;
578 }
579
580 objpool.offs = objpool.mem;
581 return objpool;
582 }
583}
584
585void DestroyObjPool(ObjPool *const restrict objpool)
586{
587 if (objpool->mem == 0) return;
588 else
589 {
590 void *const restrict ptr = ( void* )objpool->mem;
591 free(ptr);
592 *objpool = (ObjPool){0};
593 }
594}
595
596void *ObjPoolAlloc(ObjPool *const objpool)
597{
598 if (objpool->freeBlocks > 0)
599 {
600 // For first allocation, head points to the very first index.
601 // Head = &pool[0];
602 // ret = Head == ret = &pool[0];
603 size_t *const restrict block = ( size_t* )objpool->offs;
604 objpool->freeBlocks--;
605
606 // after allocating, we set head to the address of the index that *Head holds.
607 // Head = &pool[*Head * pool.objsize];
608 objpool->offs = (objpool->freeBlocks != 0)? objpool->mem + (*block*objpool->objSize) : 0;
609 return memset(block, 0, objpool->objSize);
610 }
611 else return NULL;
612}
613
614void ObjPoolFree(ObjPool *const restrict objpool, void *const ptr)
615{
616 uintptr_t block = (uintptr_t)ptr;
617 if ((ptr == NULL) || (block < objpool->mem) || (block > objpool->mem + objpool->memSize*objpool->objSize)) return;
618 else
619 {
620 // When we free our pointer, we recycle the pointer space to store the previous index and then we push it as our new head.
621 // *p = index of Head in relation to the buffer;
622 // Head = p;
623 size_t *const restrict index = ( size_t* )block;
624 *index = (objpool->offs != 0)? (objpool->offs - objpool->mem)/objpool->objSize : objpool->memSize;
625 objpool->offs = block;
626 objpool->freeBlocks++;
627 }
628}
629
630void ObjPoolCleanUp(ObjPool *const restrict objpool, void **const restrict ptrref)
631{
632 if (ptrref == NULL) return;
633 else
634 {
635 ObjPoolFree(objpool, *ptrref);
636 *ptrref = NULL;
637 }
638}
639
640
641//----------------------------------------------------------------------------------
642// Module Functions Definition - Double-Ended Stack
643//----------------------------------------------------------------------------------
644BiStack CreateBiStack(const size_t len)
645{
646 BiStack destack = { 0 };
647 if (len == 0) return destack;
648
649 uint8_t *const buf = malloc(len*sizeof *buf);
650 if (buf==NULL) return destack;
651 destack.size = len;
652 destack.mem = ( uintptr_t )buf;
653 destack.front = destack.mem;
654 destack.back = destack.mem + len;
655 return destack;
656}
657
658BiStack CreateBiStackFromBuffer(void *const buf, const size_t len)
659{
660 BiStack destack = { 0 };
661 if (len == 0 || buf == NULL) return destack;
662 else
663 {
664 destack.size = len;
665 destack.mem = destack.front = ( uintptr_t )buf;
666 destack.back = destack.mem + len;
667 return destack;
668 }
669}
670
671void DestroyBiStack(BiStack *const restrict destack)
672{
673 if (destack->mem == 0) return;
674 else
675 {
676 uint8_t *const restrict buf = ( uint8_t* )destack->mem;
677 free(buf);
678 *destack = (BiStack){0};
679 }
680}
681
682void *BiStackAllocFront(BiStack *const restrict destack, const size_t len)
683{
684 if (destack->mem == 0) return NULL;
685 else
686 {
687 const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t));
688 // front end arena is too high!
689 if (destack->front + ALIGNED_LEN >= destack->back) return NULL;
690 else
691 {
692 uint8_t *const restrict ptr = ( uint8_t* )destack->front;
693 destack->front += ALIGNED_LEN;
694 return ptr;
695 }
696 }
697}
698
699void *BiStackAllocBack(BiStack *const restrict destack, const size_t len)
700{
701 if (destack->mem == 0) return NULL;
702 else
703 {
704 const size_t ALIGNED_LEN = __AlignSize(len, sizeof(uintptr_t));
705 // back end arena is too low
706 if (destack->back - ALIGNED_LEN <= destack->front) return NULL;
707 else
708 {
709 destack->back -= ALIGNED_LEN;
710 uint8_t *const restrict ptr = ( uint8_t* )destack->back;
711 return ptr;
712 }
713 }
714}
715
716void BiStackResetFront(BiStack *const destack)
717{
718 if (destack->mem == 0) return;
719 else destack->front = destack->mem;
720}
721
722void BiStackResetBack(BiStack *const destack)
723{
724 if (destack->mem == 0) return;
725 else destack->back = destack->mem + destack->size;
726}
727
728void BiStackResetAll(BiStack *const destack)
729{
730 BiStackResetBack(destack);
731 BiStackResetFront(destack);
732}
733
734inline intptr_t BiStackMargins(const BiStack destack)
735{
736 return destack.back - destack.front;
737}
738
739#endif // RMEM_IMPLEMENTATION
740
741
#define NULL
Definition: miniaudio.h:3718
RMEMAPI BiStack CreateBiStackFromBuffer(void *buf, size_t len)
RMEMAPI size_t GetMemPoolFreeMemory(const MemPool mempool)
RMEMAPI void DestroyObjPool(ObjPool *objpool)
RMEMAPI void * MemPoolAlloc(MemPool *mempool, size_t bytes)
RMEMAPI void * ObjPoolAlloc(ObjPool *objpool)
RMEMAPI void * MemPoolRealloc(MemPool *mempool, void *ptr, size_t bytes)
RMEMAPI BiStack CreateBiStack(size_t len)
RMEMAPI MemPool CreateMemPool(size_t bytes)
RMEMAPI void * BiStackAllocFront(BiStack *destack, size_t len)
RMEMAPI ObjPool CreateObjPool(size_t objsize, size_t len)
RMEMAPI void ObjPoolFree(ObjPool *objpool, void *ptr)
RMEMAPI void * BiStackAllocBack(BiStack *destack, size_t len)
RMEMAPI void ObjPoolCleanUp(ObjPool *objpool, void **ptrref)
#define RMEMAPI
rmem - raylib memory pool and objects pool
Definition: rmem.h:55
RMEMAPI ObjPool CreateObjPoolFromBuffer(void *buf, size_t objsize, size_t len)
RMEMAPI intptr_t BiStackMargins(BiStack destack)
RMEMAPI void MemPoolFree(MemPool *mempool, void *ptr)
RMEMAPI void MemPoolReset(MemPool *mempool)
RMEMAPI void BiStackResetBack(BiStack *destack)
@ MEMPOOL_BUCKET_BITS
Definition: rmem.h:86
@ MEM_SPLIT_THRESHOLD
Definition: rmem.h:87
@ MEMPOOL_BUCKET_SIZE
Definition: rmem.h:85
RMEMAPI void MemPoolCleanUp(MemPool *mempool, void **ptrref)
RMEMAPI void DestroyMemPool(MemPool *mempool)
RMEMAPI void DestroyBiStack(BiStack *destack)
RMEMAPI MemPool CreateMemPoolFromBuffer(void *buf, size_t bytes)
RMEMAPI void BiStackResetFront(BiStack *destack)
RMEMAPI void BiStackResetAll(BiStack *destack)
_W64 unsigned int uintptr_t
Definition: stdint.h:119
unsigned char uint8_t
Definition: stdint.h:78
_W64 signed int intptr_t
Definition: stdint.h:118
Definition: rmem.h:72
MemNode * head
Definition: rmem.h:73
size_t len
Definition: rmem.h:74
MemNode * tail
Definition: rmem.h:73
Definition: rmem.h:78
uintptr_t mem
Definition: rmem.h:79
size_t size
Definition: rmem.h:80
uintptr_t offs
Definition: rmem.h:79
Definition: rmem.h:104
uintptr_t mem
Definition: rmem.h:105
uintptr_t front
Definition: rmem.h:105
uintptr_t back
Definition: rmem.h:105
size_t size
Definition: rmem.h:106
Definition: rmem.h:66
size_t size
Definition: rmem.h:67
MemNode * prev
Definition: rmem.h:68
MemNode * next
Definition: rmem.h:68
Definition: rmem.h:90
AllocList large
Definition: rmem.h:91
Arena arena
Definition: rmem.h:92
AllocList buckets[MEMPOOL_BUCKET_SIZE]
Definition: rmem.h:91
Definition: rmem.h:97
uintptr_t mem
Definition: rmem.h:98
uintptr_t offs
Definition: rmem.h:98
size_t objSize
Definition: rmem.h:99
size_t memSize
Definition: rmem.h:99
size_t freeBlocks
Definition: rmem.h:99