GitOS
Operating system exercise
Loading...
Searching...
No Matches
heap.h
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3#include <stddef.h>
4
5#define HEAP_BLOCK_TABLE_ENTRY_TAKEN 0x01
6#define HEAP_BLOCK_TABLE_ENTRY_FREE 0x00
7
8#define HEAP_BLOCK_HAS_NEXT 0b10000000
9#define HEAP_BLOCK_IS_FIRST 0b01000000
10
11typedef unsigned char HEAP_BLOCK_TABLE_ENTRY;
12
13typedef struct
14{
16 size_t total;
18
19typedef struct
20{
23} heap;
24
25#define HEAP_TABLE_ADDRESS 0x00007e00
26#define HEAP_BLOCK_SIZE 4096
27
28int heap_create(heap* heap, heap_table* table, void* ptr, void* end);
29void* heap_malloc(heap* heap, size_t size);
30void heap_free(heap* heap, void* ptr);
uint16_t size
Definition gdt.h:0
void heap_free(heap *heap, void *ptr)
Frees specified pointer in heap.
Definition heap.c:223
int heap_create(heap *heap, heap_table *table, void *ptr, void *end)
Creates heap in specified chunk of memory.
Definition heap.c:186
void * heap_malloc(heap *heap, size_t size)
unsigned char HEAP_BLOCK_TABLE_ENTRY
Definition heap.h:11
Definition heap.h:14
HEAP_BLOCK_TABLE_ENTRY * entries
Definition heap.h:15
size_t total
Definition heap.h:16
Definition heap.h:20
heap_table * table
Definition heap.h:21
void * start_address
Definition heap.h:22