- Alloc only chars or u8
- Create STB-style header file
- Write usage
- Create examples
- Fix
c89 - Create 'stack' version (optional)
STB-style library for Region-based memory management. Created for educational purposes.
You can download repository and run
make demo. Is repeats the following information.
To include library (remove #define to include only header part):
#define RB_ALLOC_IMPLEMENTATION
#include "rb_alloc.h"First of all, you need to initialize region
(you may want to redefine REGION_SIZE, default value is 2048 bytes):
Region *region = regionInit(REGION_SIZE);After that, you work with region like with default malloc:
const size_t ROWS = 3;
const size_t COLS = 4;
double** matrix = regionAlloc(region, sizeof(double*)*ROWS);
for (size_t i = 0; i < ROWS; i++)
matrix[i] = regionAlloc(region, sizeof(double)*COLS);After all, you need to free region:
regionFree(region);For debug purposes you can print region information:
regionDump(region);It prints all information about region.
- STB-style library: https://github.com/nothings/stb
- Region-based memory management: https://en.wikipedia.org/wiki/Region-based_memory_management