diff options
| author | Federico Angelilli <code@fedang.net> | 2024-11-18 23:29:26 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-11-18 23:29:26 +0100 |
| commit | ca2cf9265e2030a9098f18315e3addde7f518192 (patch) | |
| tree | 52c4663887ad50cea1bbc44484300bb2dafacc9a /src/format.c | |
| parent | 38637de243c569c0d6aaff455752e617c30c5866 (diff) | |
Refactor
Diffstat (limited to 'src/format.c')
| -rw-r--r-- | src/format.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/format.c b/src/format.c index 4657359..8f42c00 100644 --- a/src/format.c +++ b/src/format.c @@ -7,13 +7,13 @@ #include "any_log.h" #include "util.h" -#define format_grow() \ +#define format_grow(need) \ do { \ if (n + 1 >= length) { \ - length += 4; \ + length += (need); \ parts = realloc(parts, length * sizeof(char *)); \ assert(parts != NULL); \ - marks = realloc(marks, length * sizeof(bool)); \ + marks = realloc(marks, length * sizeof(uint8_t)); \ assert(marks != NULL); \ } \ } while (0) @@ -31,7 +31,7 @@ bool format_init(format_t *format, const char *string, char delim) // TODO: Escape formatting if (string[end + 1] == '{') { - format_grow(); + format_grow(2); if (start != end) { parts[n] = strslice(string, start, end); @@ -74,7 +74,7 @@ next: if (start != end || string[end] != '\0') { while (string[end] != '\0') end++; - format_grow(); + format_grow(1); parts[n] = strslice(string, start, end); marks[n] = false; n++; |
