summaryrefslogtreecommitdiffstats
path: root/core/table.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-04 20:59:08 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-06-19 13:11:10 -0700
commit3df32044ee46caf518b23cc6359f98501f7ca961 (patch)
tree860615069cf0b5f36627b0815d374c66e265dbde /core/table.h
parentf4ef1c4bc8805600e018777f18f3f29682e40c2d (diff)
downloadsubsurface-3df32044ee46caf518b23cc6359f98501f7ca961.tar.gz
Cleanup: generate clear_*_table() functions by macro
In analogy to the other table functions, generate these by a macro as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/table.h')
-rw-r--r--core/table.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/table.h b/core/table.h
index 1abfa6be3..da0bc96a5 100644
--- a/core/table.h
+++ b/core/table.h
@@ -91,4 +91,12 @@
return idx; \
}
+#define MAKE_CLEAR_TABLE(table_type, array_name, item_name) \
+ void clear_##table_type(struct table_type *table) \
+ { \
+ for (int i = 0; i < table->nr; i++) \
+ free_##item_name(table->array_name[i]); \
+ table->nr = 0; \
+ }
+
#endif