mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: fix memory leak in tables code
The function clear_*_table frees all elements of the table. However, persumably as a performance feature, it kept the memory of the table itselt (i.e. it only reset the number of elements but kept the capacity). That is fine if the table is reused later. However, this function was also used when freeing the table and this would leak the table memory. This commit frees the table memory. An alternative would be to have separate clear_*_table and free_*_table functions. But let's wait with that until we port the table code to C++. Then this will be "automatically" fixed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
805cd550f2
commit
9d2bd425e1
1 changed files with 3 additions and 0 deletions
|
@ -96,6 +96,9 @@
|
|||
{ \
|
||||
for (int i = 0; i < table->nr; i++) \
|
||||
free_##item_name(table->array_name[i]); \
|
||||
free(table->array_name); \
|
||||
table->array_name = NULL; \
|
||||
table->allocated = 0; \
|
||||
table->nr = 0; \
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue