Unused headers, remove some specific asserts, some reference notes on wiping block

This commit is contained in:
Imbus 2025-09-09 10:19:12 +02:00
parent f97505d8ba
commit 8fb583b57f

View file

@ -1,10 +1,4 @@
#include "freelist.h"
#include "stddef.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct __attribute__((packed)) FreeListBlock {
uint16_t next_offset;
@ -36,8 +30,6 @@ int fl_init(FreeList *fl, uintptr_t start, size_t size_bytes, size_t itemsize) {
* but MAX_ALIGN_T is also an option. Especially for allocator implementation. */
size_t size = align_up_to(itemsize, sizeof(void *));
assert(sizeof(FreeListBlock) == 2);
if (size < sizeof(FreeListBlock) || !fl)
return 0;
@ -69,7 +61,14 @@ void *fl_alloc(FreeList *fl) {
fl->free = offset_to_ptr(fl, fl->free->next_offset); /* May be null, which is fine */
fl->allocated++;
memset((void *)m, 0, sizeof(FreeListBlock));
/* Wipe it before sending it out, could use memset
* here, or even wiping the entire block */
m->next_offset = 0;
/* For reference: */
// memset((void *)m, 0, fl->size); /* Wipe entire block */
// memset((void *)m, 0, sizeof(FreeListBlock)); /* Wipe only header */
return ((void *)m);
}