1 #ifndef _INCLUDE_MEMFILE_H
2 #define _INCLUDE_MEMFILE_H
6 typedef struct memfile_s
17 * Creates a new memory file
18 * init is the initial size in bytes
20 memfile_t *memfile_creat(const char *name, size_t init);
23 * Frees the memory associated.
25 void memfile_destroy(memfile_t *mf);
28 * Seeks to a given offset (always from start)
30 void memfile_seek(memfile_t *mf, long seek);
33 * Writes to a memory buffer (expands as necessary).
34 * Returns 1 on success, 0 on failure.
36 int memfile_write(memfile_t *mf, const void *buffer, size_t size);
39 * Reads a number of bytes from a memory buffer.
40 * Returns the number of bytes read until the end was hit.
42 size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize);
45 * Returns the current position from the start.
47 long memfile_tell(memfile_t *mf);
50 * Resets all the states of the memory buffer.
51 * (does not actually free or zero memory)
53 void memfile_reset(memfile_t *mf);
55 #endif //_INCLUDE_MEMFILE_H