agssim: improve error reporting
[rofl0r-agsutils.git] / MemGrow.h
blobbc82bb5f97b2b40f200feb29eefd89c48f9b2169
1 #ifndef MEMGROW_H
2 #define MEMGROW_H
4 #include <stddef.h>
5 #include <stdio.h>
7 typedef struct MemGrow {
8 void* mem;
9 size_t used;
10 size_t capa;
11 } MG;
13 void mem_init(MG* mem);
14 void mem_free(MG* mem);
15 int mem_grow_if_needed(MG *mem, size_t newsize);
16 int mem_write(MG *mem, size_t offset, void* data, size_t size);
17 int mem_append(MG *mem, void* data, size_t size);
18 void* mem_getptr(MG* mem, size_t offset, size_t byteswanted);
19 void mem_set(MG* mem, void* data, size_t used, size_t allocated);
20 int mem_write_file(MG* mem, char* fn);
21 int mem_write_stream(MG* mem, FILE* out);
23 #pragma RcB2 DEP "MemGrow.c"
25 #endif