From: Sebastian Harl Date: Fri, 2 Jan 2015 11:33:50 +0000 (+0100) Subject: data: Free binary and regex array values as well. X-Git-Tag: sysdb-0.7.0~90 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e77d39dc08f318db6fcf233e85c93e347a03f80f;p=sysdb.git data: Free binary and regex array values as well. --- diff --git a/src/core/data.c b/src/core/data.c index 2665165..8c54c93 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -166,6 +166,34 @@ free_array_values(sdb_data_t *datum) v[i] = NULL; } } + else if (type == SDB_TYPE_BINARY) { + struct { + size_t length; + unsigned char *datum; + } *v = datum->data.array.values; + size_t i; + + for (i = 0; i < datum->data.array.length; ++i) { + if (v[i].datum) + free(v[i].datum); + v[i].datum = NULL; + } + } + else if (type == SDB_TYPE_REGEX) { + struct { + char *raw; + regex_t regex; + } *v = datum->data.array.values; + size_t i; + + for (i = 0; i < datum->data.array.length; ++i) { + if (v[i].raw) { + free(v[i].raw); + regfree(&v[i].regex); + } + v[i].raw = NULL; + } + } } /* free_array_values */ /* compare two arrays element-by-element returning how the first non-equal