summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/strvec.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/strvec.c b/src/strvec.c
index dbc964e..13699a3 100644
--- a/src/strvec.c
+++ b/src/strvec.c
@@ -47,10 +47,14 @@ strvec_alloc(size_t cap, struct allocator *allocator, int *_rc)
rc = _rc ? _rc : &stub;
strvec = allocator->alloc(sizeof(struct strvec), rc);
+ if (!strvec && _rc) *rc = -*rc;
if (!strvec) return NULL;
*rc = strvec_init(strvec, cap, allocator);
- if (*rc) return NULL;
+ if (*rc) {
+ allocator->free(strvec);
+ return NULL;
+ }
return strvec;
}
@@ -71,8 +75,9 @@ strvec_free(struct strvec *strvec)
rc = allocator->free(strvec);
LIBSTRVEC_ABORT_ON_ALLOC(rc);
+ if (rc) return -rc;
- return rc;
+ return 0;
}
int