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 <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2023-06-08 09:05:39 -05:00
committed by Serge Hallyn
parent 09775d3718
commit f2ac1e2540
+7 -11
View File
@@ -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;