diff options
author | Phil Jones <philj56@gmail.com> | 2021-11-15 19:37:48 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2021-11-15 19:37:48 +0000 |
commit | 49c7405b6a88e56bb69e12189adb719927343e07 (patch) | |
tree | 72c7691e746563cc1396c5b555659c813572c12e /src/string_vec.c | |
parent | 108df42e561b7e81ba09a8c278a562129e651bb6 (diff) |
Multiple smaller changes.
- Remove the background image and libpng dependency
- Add a prompt
- Add xmalloc with out-of-memory handling
- Add beginnings of a rofi-like run cache
Diffstat (limited to 'src/string_vec.c')
-rw-r--r-- | src/string_vec.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/string_vec.c b/src/string_vec.c index f747339..d3ac9fe 100644 --- a/src/string_vec.c +++ b/src/string_vec.c @@ -2,6 +2,7 @@ #include <stdlib.h> #include <string.h> #include "string_vec.h" +#include "xmalloc.h" static int cmpstringp(const void *restrict a, const void *restrict b) { @@ -29,7 +30,7 @@ struct string_vec string_vec_create(void) struct string_vec vec = { .count = 0, .size = 128, - .buf = calloc(128, sizeof(char *)) + .buf = xcalloc(128, sizeof(char *)) }; return vec; } @@ -47,7 +48,7 @@ struct string_vec string_vec_copy(struct string_vec *restrict vec) struct string_vec copy = { .count = vec->count, .size = vec->size, - .buf = calloc(vec->size, sizeof(char *)) + .buf = xcalloc(vec->size, sizeof(char *)) }; for (size_t i = 0; i < vec->count; i++) { @@ -61,7 +62,7 @@ void string_vec_add(struct string_vec *restrict vec, const char *restrict str) { if (vec->count == vec->size) { vec->size *= 2; - vec->buf = realloc(vec->buf, vec->size * sizeof(vec->buf[0])); + vec->buf = xrealloc(vec->buf, vec->size * sizeof(vec->buf[0])); } vec->buf[vec->count] = strdup(str); vec->count++; |