Core: implement move functions for dive and dive_site table

To allow efficient moving of downloaded dives from the download
thread to the model, implement a general move function that
moves table data. Instantiate that function for the dive and
dive_site tables.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-09-25 20:17:41 +02:00 committed by Dirk Hohndel
parent eecca6aab0
commit 6e343c734a
5 changed files with 15 additions and 0 deletions

View file

@ -99,4 +99,15 @@
table->nr = 0; \
}
/* Move data of one table to the other - source table is empty after call. */
#define MAKE_MOVE_TABLE(table_type, array_name) \
void move_##table_type(struct table_type *src, struct table_type *dst) \
{ \
clear_##table_type(dst); \
free(dst->array_name); \
*dst = *src; \
src->nr = src->allocated = 0; \
src->array_name = NULL; \
}
#endif