Better comments
This commit is contained in:
parent
dcfd4c01ff
commit
c0811e1a95
1 changed files with 4 additions and 3 deletions
|
|
@ -1,7 +1,8 @@
|
|||
#include "freelist.h"
|
||||
|
||||
/* Header block used to keep track of all the free blocks */
|
||||
struct __attribute__((packed)) FreeListBlock {
|
||||
uint16_t next_offset;
|
||||
uint16_t next_offset; /* May be 8, 16, 32, 64, whatever */
|
||||
};
|
||||
|
||||
/* Align to nearest multiple of align */
|
||||
|
|
@ -9,7 +10,7 @@ static inline size_t align_up_to(size_t n, size_t align) {
|
|||
return (n + align - 1) & ~(align - 1);
|
||||
}
|
||||
|
||||
// Convert pointer -> 1-based offset (0 means NULL)
|
||||
/* Convert pointer -> 1-based offset (0 means NULL) */
|
||||
static inline uint32_t ptr_to_offset(FreeList *fl, void *ptr) {
|
||||
if (!ptr)
|
||||
return 0; // NULL maps to 0
|
||||
|
|
@ -17,7 +18,7 @@ static inline uint32_t ptr_to_offset(FreeList *fl, void *ptr) {
|
|||
return (uint32_t)(diff / fl->size) + 1;
|
||||
}
|
||||
|
||||
// Convert 1-based offset -> pointer (0 means NULL)
|
||||
/* Convert 1-based offset -> pointer (0 means NULL) */
|
||||
static inline void *offset_to_ptr(FreeList *fl, uint32_t offset) {
|
||||
if (offset == 0)
|
||||
return NULL; // 0 = invalid/null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue