diff options
| author | Mattias Andrée <m@maandree.se> | 2026-01-03 03:52:00 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-01-03 03:52:00 +0100 |
| commit | f95225f2db5e125bab1dedbb5b2e68d3a687f8f6 (patch) | |
| tree | 805e260207bc2a58029bf0dd7a372c8c0f6b117b | |
| parent | Add IS_HIDDEN to make meaning clearer (diff) | |
| download | libparser-f95225f2db5e125bab1dedbb5b2e68d3a687f8f6.tar.gz libparser-f95225f2db5e125bab1dedbb5b2e68d3a687f8f6.tar.bz2 libparser-f95225f2db5e125bab1dedbb5b2e68d3a687f8f6.tar.xz | |
Portability-fix: NULL is not necessarily 0, so calloc cannot be used for assigning NULL
Signed-off-by: Mattias Andrée <m@maandree.se>
| -rw-r--r-- | libparser.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libparser.c b/libparser.c index 4a42c43..ce26273 100644 --- a/libparser.c +++ b/libparser.c @@ -53,18 +53,19 @@ try_match(const char *rule, const union libparser_sentence *sentence, struct con size_t i; if (!ctx->cache) { - unit = calloc(1, sizeof(*unit)); + unit = malloc(sizeof(*unit)); if (!unit) { ctx->done = 1; ctx->error = 1; return NULL; } + unit->end = 0; } else { unit = ctx->cache; ctx->cache = unit->next; - unit->in = unit->next = NULL; } + unit->in = unit->next = NULL; unit->rule = rule; unit->start = ctx->position; |
