Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions lib/subordinateio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <string.h>

#include "alloc/malloc.h"
#include "alloc/realloc.h"
#include "alloc/reallocf.h"
#include "atoi/str2i.h"
#include "string/ctype/strisascii/strisdigit.h"
Expand Down Expand Up @@ -276,19 +275,17 @@ static const struct subordinate_range *find_range(struct commonio_db *db,
static bool have_range(struct commonio_db *db,
const char *owner, unsigned long start, unsigned long count);

static bool append_range(struct subid_range **ranges, const struct subordinate_range *new, int n)
static struct subid_range *
append_range(struct subid_range *ranges, const struct subordinate_range *new, int n)
{
struct subid_range *sr;

sr = REALLOC(*ranges, n + 1, struct subid_range);
if (!sr)
return false;
ranges = REALLOCF(ranges, n + 1, struct subid_range);
if (ranges == NULL)
return NULL;

sr[n].start = new->start;
sr[n].count = new->count;
*ranges = sr;
ranges[n].start = new->start;
ranges[n].count = new->count;

return true;
return ranges;
}

void free_subordinate_ranges(struct subordinate_range **ranges, int count)
Expand Down Expand Up @@ -920,9 +917,8 @@ int list_owner_ranges(const char *owner, enum subid_type id_type, struct subid_r
if ( streq(range->owner, owner)
|| (have_owner_id && streq(range->owner, id)))
{
if (!append_range(&ranges, range, count++)) {
free(ranges);
ranges = NULL;
ranges = append_range(ranges, range, count++);
if (ranges == NULL) {
count = -1;
goto out;
}
Expand Down
Loading