Bladeren bron

Started work on types and prototypes

watermark_alloc
Thomas Johnson 1 jaar geleden
bovenliggende
commit
7719e8f36c
  1. 49
      allocator_internal.h

49
allocator_internal.h

@ -0,0 +1,49 @@
#ifndef ALLOCATOR_INTERNAL_H
#define ALLOCATOR_INTERNAL_H
#include <stdint.h>
#include <sys/types.h>
// No enum because these need to be 1 byte
const char RT_FREESPACE = 0;
const char RT_TREE_NODE = 1;
const char RT_WATERMARK = 2;
struct TopLevel {
struct FreeSpace *root_freespace;
struct TreeAlloc *root_treealloc;
}
// All three of these types should be memory-compatible with each other
struct TreeAlloc {
char type; // Should be RT_TREE_NODE
struct TreeAlloc *parent;
struct TreeAlloc *left;
struct TreeAlloc *right;
size_t size;
}
struct FreeSpace {
char type; // Should be RT_FREESPACE
struct FreeSpace *parent;
struct FreeSpace *left;
struct FreeSpace *right;
size_t size;
}
struct WatermarkAlloc {
char type; // Should be RT_WATERMARK
struct TreeAlloc *parent;
struct TreeAlloc *left;
struct TreeAlloc *right;
size_t size;
int num_allocs;
void *next_alloc;
}
struct TreeAlloc *insert_node_at(void *address, int padding, int align, int size);
struct TreeAlloc *search_by_address(TreeAlloc *root, void *address);
struct TreeAlloc *search_by_size(TreeAlloc *root, int padding, int align, int size);
#endif
Laden…
Annuleren
Opslaan