CustomHeapManager/include/CHM.h

37 lines
1.1 KiB
C
Raw Permalink Normal View History

#pragma once
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/syscall.h>
enum MemMode : unsigned char
{
MEM_MODE_SPEED, // Memory will be allocated more quickly but loses memory efficiency.
MEM_MODE_EFFICIENCY, // Memory will be allocated more slowly but gains memory efficiency.
MEM_MODE_BALANCED // Memory will be allocated as quickly as possible but also for the sake of memory efficiency.
};
void set_memory_mode(enum MemMode new_mode);
enum MemMode get_memory_mode();
/// Will find or allocate a memory block appropriately.
/// @param [in] size The size of the memory block to request.
/// @returns The allocated memory address on the heap.
void *malloc(size_t size);
void *realloc(void *ptr, size_t newSize);
/// Will flag the provided memory as free and will defragment other blocks adjacent to it.
/// @param [in] ptr The memory to flag as free.
void free(void *ptr);
2024-03-02 12:55:54 -08:00
size_t get_header_size();
/// Will retrieve the current real byte size of the heap.
/// @returns The size in bytes.
size_t get_heap_size();
2024-03-02 12:55:54 -08:00
void cleanup_memory();