project_files/frontlib/util/buffer.h
changeset 7271 5608ac657362
parent 7234 613998625a3c
child 7275 15f722e0b96f
equal deleted inserted replaced
7269:5b0aeef8ba2a 7271:5608ac657362
    24 } flib_constbuffer;
    24 } flib_constbuffer;
    25 
    25 
    26 /**
    26 /**
    27  * Simple variable-capacity data structure that can be efficiently appended to.
    27  * Simple variable-capacity data structure that can be efficiently appended to.
    28  */
    28  */
    29 struct _flib_vector;
       
    30 typedef struct _flib_vector flib_vector;
    29 typedef struct _flib_vector flib_vector;
    31 
    30 
    32 /**
    31 /**
    33  * Create a new vector. Needs to be destroyed again later with flib_vector_destroy.
    32  * Create a new vector. Needs to be destroyed again later with flib_vector_destroy.
    34  * May return NULL if memory runs out.
    33  * May return NULL if memory runs out.
    53  * The vector remains unchanged if appending fails.
    52  * The vector remains unchanged if appending fails.
    54  */
    53  */
    55 int flib_vector_append(flib_vector *vec, const void *data, size_t len);
    54 int flib_vector_append(flib_vector *vec, const void *data, size_t len);
    56 
    55 
    57 /**
    56 /**
       
    57  * Append data from a format string to the buffer (without trailing 0)
       
    58  * Returns 0 on success.
       
    59  */
       
    60 int flib_vector_appendf(flib_vector *vec, const char *template, ...);
       
    61 
       
    62 /**
    58  * Return a pointer to the current data buffer of the vector. This pointer can
    63  * Return a pointer to the current data buffer of the vector. This pointer can
    59  * become invalid if the vector size or capacity is changed.
    64  * become invalid if the vector size or capacity is changed.
    60  */
    65  */
    61 void *flib_vector_data(flib_vector *vec);
    66 void *flib_vector_data(flib_vector *vec);
    62 
    67