aboutsummaryrefslogtreecommitdiffstats
path: root/include/heap.h
blob: e8cd9c1e204d56d9e2ddf9b783fde736cef3cf9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
 * @file heap.h
 * A basic memory manager
 */

#ifndef HEAP_H_
#define HEAP_H_

#include <stdint.h>

/**
 * Initializes memory management of the given heap.
 * No overflow stuff is done, so...
 * @param buf the heap to use for allocations
 */
void heap_init(void *buf);

/**
 * Allocates a chunk of memory.
 * @param size how many bytes to claim
 * @return pointer to the allocated buffer
 */
void *malloc(uint32_t size);

/**
 * Allocates and zeros a chunk of memory.
 * @param count how many of whatever to allocate
 * @param size byte count of each whatever
 * @return pointer to the allocated buffer
 */
void *calloc(uint32_t count, uint32_t size);

/**
 * Frees the buffer allocated through malloc/calloc.
 * Please don't double-free.
 * @param the buffer to release
 */
void free(void *buf);

#endif // HEAP_H_