Add some buffer management routines
This commit is contained in:
25
libXmd/include/Xmd/Buffer.h
Normal file
25
libXmd/include/Xmd/Buffer.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _XmdBuffer_h
|
||||
#define _XmdBuffer_h
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* Buffer is a struct that keeps track of a variable length array of data. It
|
||||
is like a piggy bank, you can add stuff to it and then break it to get access
|
||||
to all the things you put in. It is intended to be used for reading in
|
||||
variable length strings and files. */
|
||||
typedef struct _XmdBuffer XmdBuffer;
|
||||
|
||||
/* XmdBufferNew creates a new buffer with the specified element size. */
|
||||
XmdBuffer *XmdBufferNew (size_t element);
|
||||
|
||||
/* XmdBufferPush adds a new element to the buffer. */
|
||||
void XmdBufferPush (XmdBuffer *buffer, void *element);
|
||||
|
||||
/* XmdBufferBreak frees the buffer without freeing its data. Its data is
|
||||
returned and must be freed manually at some point. */
|
||||
void *XmdBufferBreak (XmdBuffer *buffer);
|
||||
|
||||
/* XmdBufferFree frees the buffer and any data associated with it. */
|
||||
void XmdBufferFree (XmdBuffer *buffer);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user