arena allocator
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#ifndef LIBFLINT_H_MATH
|
||||
#define LIBFLINT_H_MATH
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "lfutility.h"
|
||||
|
||||
int max_int(int a, int b);
|
||||
@ -11,6 +13,8 @@ int clamp_int(int i, int low, int high);
|
||||
|
||||
int binstr_to_int(const char *s);
|
||||
|
||||
int is_power_of_two(int i);
|
||||
|
||||
Point *bresenham(int x0, int y0, int x1, int y1, size_t *sz);
|
||||
|
||||
Point *bresenham_p(Point p1, Point p2, size_t *sz);
|
||||
|
20
include/lfmemory.h
Normal file
20
include/lfmemory.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef LIBFLINT_H_MEMORY
|
||||
#define LIBFLINT_H_MEMORY
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned char* buf;
|
||||
size_t buf_sz;
|
||||
size_t offset_cur;
|
||||
size_t offset_prev;
|
||||
} ArenaAllocator;
|
||||
|
||||
void arena_init(ArenaAllocator *allocator, size_t buf_sz);
|
||||
void arena_free(ArenaAllocator *allocator);
|
||||
void *arena_malloc(ArenaAllocator* allocator, size_t size);
|
||||
void arena_resize_buf(ArenaAllocator *allocator, size_t new_sz);
|
||||
void *arena_resize(ArenaAllocator *allocator, void *mem, size_t old_sz, size_t new_sz);
|
||||
void arena_clear(ArenaAllocator *allocator);
|
||||
|
||||
#endif // LIBFLINT_H_MEMORY
|
Reference in New Issue
Block a user