first commit

This commit is contained in:
2024-04-19 02:11:41 +02:00
commit 60ff621676
5 changed files with 555 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#include <stddef.h>
#include <stdint.h>
struct buddy_alloc {
void *base;
void *lists[5];
uint32_t *bitsets;
int num_bitsets;
};
void init_buddy_alloc(struct buddy_alloc *alloc,
char *base, size_t size,
uint32_t *bitsets, int num_bitsets);
void free_buddy_alloc(struct buddy_alloc *alloc);
void *buddy_malloc(struct buddy_alloc *alloc,
size_t len);
void buddy_free(struct buddy_alloc *alloc,
void *ptr, size_t len);
bool buddy_allocated(struct buddy_alloc *alloc,
void *ptr, size_t len);