From f2ac1e254044aa7de1bd4b8deb08b8017813f730 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Sat, 27 May 2023 15:35:13 +0200 Subject: [PATCH] realloc(NULL, ...) is equivalent to malloc(...) Don't have a branch for when the old pointer is NULL. realloc(3) can handle that case just fine. Signed-off-by: Alejandro Colomar --- lib/subordinateio.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 49356e23a..52d0e33d1 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -315,17 +315,13 @@ static bool have_range(struct commonio_db *db, static bool append_range(struct subid_range **ranges, const struct subordinate_range *new, int n) { - if (!*ranges) { - *ranges = MALLOC(1, struct subid_range); - if (!*ranges) - return false; - } else { - struct subid_range *alloced; - alloced = REALLOC(*ranges, n + 1, struct subid_range); - if (!alloced) - return false; - *ranges = alloced; - } + struct subid_range *alloced; + + alloced = REALLOC(*ranges, n + 1, struct subid_range); + if (!alloced) + return false; + *ranges = alloced; + (*ranges)[n].start = new->start; (*ranges)[n].count = new->count; return true; -- 2.47.2