BUG_ON(set->ncomps > set->total);
if (set->ncomps == set->total) {
+ void *tmp;
+
size = set->total + BTRFS_LIST_NCOMPS_INCREASE;
size = sizeof(*set) + size * sizeof(struct btrfs_list_comparer);
+ tmp = set;
set = realloc(set, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
+ free(tmp);
exit(1);
}
BUG_ON(set->nfilters > set->total);
if (set->nfilters == set->total) {
+ void *tmp;
+
size = set->total + BTRFS_LIST_NFILTERS_INCREASE;
size = sizeof(*set) + size * sizeof(struct btrfs_list_filter);
+ tmp = set;
set = realloc(set, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
+ free(tmp);
exit(1);
}
}
return p;
}
- if (avail == -1)
+ if (avail == -1) {
+ free_history(p);
return ERR_PTR(-errno);
+ }
avail += old_avail;
i = 0;
while (i < avail) {
+ void *tmp;
+
switch (state) {
case 0: /* start of file */
ret = scrub_kvread(&i,
continue;
}
++curr;
+ tmp = p;
p = realloc(p, (curr + 2) * sizeof(*p));
- if (p)
- p[curr] = malloc(sizeof(**p));
- if (!p || !p[curr])
+ if (!p) {
+ free_history(tmp);
return ERR_PTR(-errno);
+ }
+ p[curr] = malloc(sizeof(**p));
+ if (!p[curr]) {
+ free_history(p);
+ return ERR_PTR(-errno);
+ }
memset(p[curr], 0, sizeof(**p));
p[curr + 1] = NULL;
++state;
static int add_clone_source(struct btrfs_send *s, u64 root_id)
{
+ void *tmp;
+
+ tmp = s->clone_sources;
s->clone_sources = realloc(s->clone_sources,
sizeof(*s->clone_sources) * (s->clone_sources_count + 1));
- if (!s->clone_sources)
+ if (!s->clone_sources) {
+ free(tmp);
return -ENOMEM;
+ }
s->clone_sources[s->clone_sources_count++] = root_id;
return 0;
BUG_ON(set->ncomps > set->total);
if (set->ncomps == set->total) {
+ void *tmp;
+
size = set->total + BTRFS_QGROUP_NCOMPS_INCREASE;
size = sizeof(*set) +
size * sizeof(struct btrfs_qgroup_comparer);
+ tmp = set;
set = realloc(set, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
+ free(tmp);
exit(1);
}
BUG_ON(set->nfilters > set->total);
if (set->nfilters == set->total) {
+ void *tmp;
+
size = set->total + BTRFS_QGROUP_NFILTERS_INCREASE;
size = sizeof(*set) + size * sizeof(struct btrfs_qgroup_filter);
+ tmp = set;
set = realloc(set, size);
if (!set) {
fprintf(stderr, "memory allocation failed\n");
+ free(tmp);
exit(1);
}
memset(&set->filters[set->total], 0,