Unused headers, remove some specific asserts, some reference notes on wiping block
This commit is contained in:
parent
f97505d8ba
commit
8fb583b57f
1 changed files with 8 additions and 9 deletions
|
|
@ -1,10 +1,4 @@
|
||||||
#include "freelist.h"
|
#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 {
|
struct __attribute__((packed)) FreeListBlock {
|
||||||
uint16_t next_offset;
|
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. */
|
* but MAX_ALIGN_T is also an option. Especially for allocator implementation. */
|
||||||
size_t size = align_up_to(itemsize, sizeof(void *));
|
size_t size = align_up_to(itemsize, sizeof(void *));
|
||||||
|
|
||||||
assert(sizeof(FreeListBlock) == 2);
|
|
||||||
|
|
||||||
if (size < sizeof(FreeListBlock) || !fl)
|
if (size < sizeof(FreeListBlock) || !fl)
|
||||||
return 0;
|
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->free = offset_to_ptr(fl, fl->free->next_offset); /* May be null, which is fine */
|
||||||
fl->allocated++;
|
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);
|
return ((void *)m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue