I want to cut down the size of my metadata struct for my own heap allocator. One field in my struct holds a pointer to the next instance of the struct:
typedef struct _metadata_entry_t {
struct _metadata_entry_t* next_free_block;
// signed int bytes_to_next_free_block;
} metadata;
Notice the last two fields are two ways for me to get to the next "free block". A pointer on my system (which is the only system I care about) is 8 bytes while a signed integer is 4 bytes. I think this is a good way of cutting down on the size of my struct (trading off instant access to a little bit of void pointer arithmetic). Are there any problems proceeding this way?
Additionally, since I can ensure that the addresses of these metadata structs are memory aligned to 8 bytes, maybe I can somehow truncate the address and store it in a smaller data type? Not too sure if that can be done.