Update freelist
This commit is contained in:
parent
d583dbaced
commit
ca0b25d110
2 changed files with 22 additions and 31 deletions
|
|
@ -5,18 +5,24 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FL_FREE ((uint8_t)0x00)
|
||||
#define FL_USED ((uint8_t)0x01)
|
||||
/* Align to nearest multiple of align */
|
||||
static inline size_t align_up_to(size_t n, size_t align) {
|
||||
return (n + align - 1) & ~(align - 1);
|
||||
}
|
||||
|
||||
typedef struct FreeListBlock {
|
||||
struct FreeListBlock *next;
|
||||
uint8_t block_state;
|
||||
} FreeListBlock;
|
||||
/* Fiddle these around according to your need. Delete or check makefile */
|
||||
#ifdef FREELIST_ALIGN
|
||||
#define ALIGN(x) (align_up_to(x, sizeof(void *)))
|
||||
#else
|
||||
#define ALIGN(x) (x)
|
||||
#endif
|
||||
|
||||
typedef struct FreeListBlock FreeListBlock;
|
||||
|
||||
typedef struct {
|
||||
FreeListBlock *free;
|
||||
uintptr_t start;
|
||||
uintptr_t end;
|
||||
FreeListBlock *free;
|
||||
size_t size;
|
||||
size_t allocated;
|
||||
} FreeList;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue