summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/taxonomy.c11
-rw-r--r--core/taxonomy.h1
2 files changed, 5 insertions, 7 deletions
diff --git a/core/taxonomy.c b/core/taxonomy.c
index 15086d28d..e786ba45d 100644
--- a/core/taxonomy.c
+++ b/core/taxonomy.c
@@ -26,9 +26,10 @@ char *taxonomy_api_names[TC_NR_CATEGORIES] = {
"adminName3"
};
-struct taxonomy *alloc_taxonomy()
+static void alloc_taxonomy_table(struct taxonomy_data *t)
{
- return calloc(TC_NR_CATEGORIES, sizeof(struct taxonomy));
+ if (!t->category)
+ t->category = calloc(TC_NR_CATEGORIES, sizeof(struct taxonomy));
}
void free_taxonomy(struct taxonomy_data *t)
@@ -47,8 +48,7 @@ void copy_taxonomy(const struct taxonomy_data *orig, struct taxonomy_data *copy)
if (orig->category == NULL) {
free_taxonomy(copy);
} else {
- if (copy->category == NULL)
- copy->category = alloc_taxonomy();
+ alloc_taxonomy_table(copy);
for (int i = 0; i < TC_NR_CATEGORIES; i++) {
if (i < copy->nr) {
free((void *)copy->category[i].value);
@@ -86,8 +86,7 @@ void taxonomy_set_category(struct taxonomy_data *t, enum taxonomy_category categ
int idx = -1;
// make sure we have taxonomy data allocated
- if (!t->category)
- t->category = alloc_taxonomy();
+ alloc_taxonomy_table(t);
for (int i = 0; i < t->nr; i++) {
if (t->category[i].category == category) {
diff --git a/core/taxonomy.h b/core/taxonomy.h
index 97205a48f..84caa5baa 100644
--- a/core/taxonomy.h
+++ b/core/taxonomy.h
@@ -39,7 +39,6 @@ struct taxonomy_data {
struct taxonomy *category;
};
-struct taxonomy *alloc_taxonomy();
void free_taxonomy(struct taxonomy_data *t);
void copy_taxonomy(const struct taxonomy_data *orig, struct taxonomy_data *copy);
int taxonomy_index_for_category(const struct taxonomy_data *t, enum taxonomy_category cat);