-void cstring_expand(cstring_t *self, char x) {
- if(self->size + sizeof(x) + sizeof(char) > self->alloc) {
- self->alloc += (REALLOC_ADD * sizeof(char));
- self->text = realloc(self->text, self->alloc);
+void cstring_expand(cstring_t *self, wchar_t x) {
+ if((self->size + 2) * sizeof(wchar_t) > self->alloc) {
+ self->alloc += (REALLOC_ADD * sizeof(wchar_t));
+ if((self->value = realloc(self->value, self->alloc)) == NULL) {
+ fprintf(stderr, "%s\n", "cstring_expand() failed to reallocate memory.");
+ exit(EXIT_FAILURE);
+ }
+ }
+ self->value[self->size] = x;
+ self->value[self->size+1] = L'\0';
+ self->size = wcslen(self->value);
+}
+
+void cstring_expand_arr(cstring_t *self, wchar_t *x) {
+ if((self->size + wcslen(x) + 1) * sizeof(wchar_t) > self->alloc) {
+ self->alloc = ((self->size + wcslen(x) + 1) * sizeof(wchar_t));
+ if((self->value = realloc(self->value, self->alloc)) == NULL) {
+ fprintf(stderr, "%s\n", "cstring_expand_arr() failed to reallocate memory.");
+ exit(EXIT_FAILURE);
+ }