...
Code Block | ||||
---|---|---|---|---|
| ||||
char *cur_msg = NULL; size_t cur_msg_size = 1024; /* ... */ void lessen_memory_usage(void) { char *temp; size_t temp_size; /* ... */ if (cur_msg != NULL) { temp_size = cur_msg_size/2 + 1; temp = realloc(cur_msg, temp_size); if (temp == NULL) { /* Handle error condition */ } cur_msg = temp; cur_msg_size = temp_size; /* ensureEnsure string is null-terminated */ cur_msg[cur_msg_size - 1] = '\0'; } } /* ... */ |
...