summaryrefslogtreecommitdiff
path: root/arr.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-22 19:38:37 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-22 19:38:37 -0500
commit8da3cb956b14a7644f815a1874bdcf29a4cb711d (patch)
treedabbaf21a927fb546cac5228767f7ffe975b380b /arr.c
parentf2edda528a3babe16d9da48580bdcb696e5fa664 (diff)
got .. to work in the file selector
Diffstat (limited to 'arr.c')
-rw-r--r--arr.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arr.c b/arr.c
index 0491ef4..9d2220b 100644
--- a/arr.c
+++ b/arr.c
@@ -226,10 +226,19 @@ static void arrcstr_append_strn_(char **a, char const *s, size_t s_len) {
memcpy(*a + curr_len, s, s_len + 1);
}
+static void arrcstr_shrink_(char **a, u32 new_len) {
+ ArrHeader *hdr = arr_hdr_(*a);
+ assert(hdr->cap > new_len);
+ hdr->len = new_len;
+ (*a)[new_len] = '\0';
+}
+
// append to a C-string array
#define arrcstr_append_str(a, s) arrcstr_append_strn_(&(a), (s), strlen(s))
// take at most n bytes from s
#define arrcstr_append_strn(a, s, n) arrcstr_append_strn_(&(a), (s), (n))
+// make the string smaller
+#define arrcstr_shrink(a, n) arrcstr_shrink_(&(a), (n))
static void arr_test(void) {