mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
eecca6aab0
commit
6e343c734a
5 changed files with 15 additions and 0 deletions
|
@ -753,6 +753,7 @@ static MAKE_GET_IDX(dive_table, struct dive *, dives)
|
|||
MAKE_SORT(dive_table, struct dive *, dives, comp_dives)
|
||||
MAKE_REMOVE(dive_table, struct dive *, dive)
|
||||
MAKE_CLEAR_TABLE(dive_table, dives, dive)
|
||||
MAKE_MOVE_TABLE(dive_table, dives)
|
||||
|
||||
void insert_dive(struct dive_table *table, struct dive *d)
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@ void report_datafile_version(int version);
|
|||
int get_dive_id_closest_to(timestamp_t when);
|
||||
void clear_dive_file_data();
|
||||
void clear_dive_table(struct dive_table *table);
|
||||
void move_dive_table(struct dive_table *src, struct dive_table *dst);
|
||||
|
||||
#ifdef DEBUG_TRIP
|
||||
extern void dump_selection(void);
|
||||
|
|
|
@ -131,6 +131,7 @@ static MAKE_GET_IDX(dive_site_table, struct dive_site *, dive_sites)
|
|||
MAKE_SORT(dive_site_table, struct dive_site *, dive_sites, compare_sites)
|
||||
static MAKE_REMOVE(dive_site_table, struct dive_site *, dive_site)
|
||||
MAKE_CLEAR_TABLE(dive_site_table, dive_sites, dive_site)
|
||||
MAKE_MOVE_TABLE(dive_site_table, dive_sites)
|
||||
|
||||
int add_dive_site_to_table(struct dive_site *ds, struct dive_site_table *ds_table)
|
||||
{
|
||||
|
|
|
@ -71,6 +71,7 @@ unsigned int get_distance(const location_t *loc1, const location_t *loc2);
|
|||
struct dive_site *find_or_create_dive_site_with_name(const char *name, struct dive_site_table *ds_table);
|
||||
void purge_empty_dive_sites(struct dive_site_table *ds_table);
|
||||
void clear_dive_site_table(struct dive_site_table *ds_table);
|
||||
void move_dive_site_table(struct dive_site_table *src, struct dive_site_table *dst);
|
||||
void add_dive_to_dive_site(struct dive *d, struct dive_site *ds);
|
||||
struct dive_site *unregister_dive_from_dive_site(struct dive *d);
|
||||
|
||||
|
|
11
core/table.h
11
core/table.h
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue