- cstring_t *x = malloc(sizeof(cstring_t));
- x->text = NULL;
- x->size = x->alloc = 0;
- x->expand = cstring_expand;
- x->expand_arr = cstring_expand_arr;
- x->reset = cstring_reset;
- x->delete = cstring_delete;
+ cstring_t *x = NULL;
+ if((x = malloc(sizeof(cstring_t))) != NULL) {
+ x->text = NULL;
+ x->size = x->alloc = 0;
+ x->expand = cstring_expand;
+ x->expand_arr = cstring_expand_arr;
+ x->strip = cstring_strip;
+ x->reset = cstring_reset;
+ x->delete = cstring_delete;
+ } else {
+ fprintf(stderr, "%s\n", "cstring_init() failed to allocate memory.");
+ exit(EXIT_FAILURE);
+ }