1 #if !defined( CSTRING_H )
5 * A implementation of expandable c strings in heap memory.
7 * struct: cstring_t which defines a expandable c string type in heap memory
9 * function: cstring_init to intialize struct of type cstring_t
10 * function: cstring_t->expand to add one character to the string
11 * function: cstring_t->delete to free the allocated memory
14 * cstring_t *p = cstring_init();
15 * (p->expand)(p, 'X');
20 // The amount of memory allocated from heap when string expansion hits the
21 // allocated memory limit
22 #define REALLOC_ADD 10
24 typedef struct _cstring_t {
28 void (*expand)(struct _cstring_t *self, char x);
29 void (*expand_arr)(struct _cstring_t *self, char *x);
30 void (*reset)(struct _cstring_t *self);
31 void (*delete)(struct _cstring_t *self);
34 cstring_t *cstring_init();
35 void cstring_expand(cstring_t *self, char x);
36 void cstring_expand_arr(cstring_t *self, char *x);
37 void cstring_reset(cstring_t *self);
38 void cstring_delete(cstring_t *self);
40 #endif // !defined( CSTRING_H )