32 panic(
NULL,
"heap corruption detected in free()");
34 printf(
"heap corruption detected in free()\n");
42 panic(
NULL,
"double free detected in free()");
44 printf(
"double free detected in free()\n");
56 if (alignedSize < block->size)
68 if (alignedSize > block->
size)
79 block->
size = combinedSize;
96 void* newPtr =
malloc(size);
#define assert(expression)
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define _HEAP_LARGE_ALLOC_THRESHOLD
void _heap_acquire(void)
Acquire the heap lock.
void _heap_block_split(_heap_header_t *block, uint64_t newSize)
Splits a heap block into two blocks, the first of size bytes and the second with the remaining bytes.
list_t _heapList
A list of all blocks sorted by address.
void _heap_remove_from_free_list(_heap_header_t *block)
Removes a block from its free list.
#define _HEAP_HEADER_MAGIC
void _heap_release(void)
Release the heap lock.
@ _HEAP_ALLOCATED
Block is allocated.
@ _HEAP_MAPPED
Block is not on the heap, but mapped directly, used for large allocations.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
#define ROUND_UP(number, multiple)
#define NULL
Pointer error value.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
double remainder(double x, double y)
void * realloc(void *ptr, size_t size)
_PUBLIC int printf(const char *_RESTRICT format,...)
_PUBLIC void * malloc(size_t size)
_PUBLIC _NORETURN void abort(void)
_PUBLIC void free(void *ptr)
_PUBLIC void * memcpy(void *_RESTRICT s1, const void *_RESTRICT s2, size_t n)
struct list_entry * next
The next entry in the list.