pawengine/src/allocator.h

29 lines
637 B
C
Raw Normal View History

2025-02-09 18:48:25 +01:00
#ifndef INCLUDE_WAYLANDCLIENT_ALLOCATOR_H_
#define INCLUDE_WAYLANDCLIENT_ALLOCATOR_H_
#include "sys/types.h"
2025-03-23 20:12:34 +01:00
#define MAX_ALLOCS 256
struct Alloc {
void *start;
uint size;
struct Alloc *next;
};
struct Mem {
void *mem;
size_t mem_size;
uint count;
struct Alloc *alloc;
struct Alloc allocs[MAX_ALLOCS];
};
2025-02-09 18:48:25 +01:00
struct Mem *make_mem(size_t size);
void uninit_mem(struct Mem *mem);
void *mem_malloc(struct Mem *mem, size_t size);
void mem_free(struct Mem *mem, void *p);
2025-03-23 20:12:34 +01:00
void *malloc_or_mem_malloc(struct Mem *mem, size_t size);
void free_or_mem_free(struct Mem *mem, void *ptr);
2025-02-09 18:48:25 +01:00
#endif // INCLUDE_WAYLANDCLIENT_ALLOCATOR_H_