PatchworkOS
Loading...
Searching...
No Matches
malloc.c
Go to the documentation of this file.
1#include <stdlib.h>
2
3#include "common/heap.h"
4
5void* malloc(size_t size)
6{
8
9 _heap_header_t* block = _heap_alloc(size);
10 if (block == NULL)
11 {
13 return NULL;
14 }
15
16 // When this function returns we have no way of knowing whether the caller
17 // will fill the memory or not, so we clear the zeroed flag.
18 block->flags &= ~_HEAP_ZEROED;
19
21 return block->data;
22}
void _heap_acquire(void)
Acquire the heap lock.
Definition heap.c:81
_heap_header_t * _heap_alloc(uint64_t size)
Allocates a block of memory of given size.
Definition heap.c:199
void _heap_release(void)
Release the heap lock.
Definition heap.c:90
#define NULL
Pointer error value.
Definition NULL.h:23
void * malloc(size_t size)
Definition malloc.c:5
uint8_t data[]
Definition heap.h:73
_heap_flags_t flags
Definition heap.h:69