mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add another helper funtion
We need to be able to get rid of dive sites as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d2baa36312
commit
d8146445fc
2 changed files with 20 additions and 0 deletions
19
divesite.c
19
divesite.c
|
@ -67,6 +67,25 @@ struct dive_site *alloc_dive_site()
|
|||
return ds;
|
||||
}
|
||||
|
||||
void delete_dive_site(uint32_t id)
|
||||
{
|
||||
int nr = dive_site_table.nr;
|
||||
for (int i = 0; i < nr; i++) {
|
||||
struct dive_site *ds = get_dive_site(i);
|
||||
if (ds->uuid == id) {
|
||||
free(ds->name);
|
||||
free(ds->notes);
|
||||
free(ds);
|
||||
if (nr - 1 > i)
|
||||
memmove(&dive_site_table.dive_sites[i],
|
||||
&dive_site_table.dive_sites[i+1],
|
||||
(nr - 1 - i) * sizeof(dive_site_table.dive_sites[0]));
|
||||
dive_site_table.nr = nr - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* allocate a new site and add it to the table */
|
||||
uint32_t create_dive_site(const char *name)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ static inline struct dive_site *get_dive_site_by_uuid(uint32_t uuid)
|
|||
}
|
||||
|
||||
struct dive_site *alloc_dive_site();
|
||||
void delete_dive_site(uint32_t id);
|
||||
uint32_t create_dive_site(const char *name);
|
||||
uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees_t longitude);
|
||||
uint32_t get_dive_site_uuid_by_name(const char *name, struct dive_site **dsp);
|
||||
|
|
Loading…
Add table
Reference in a new issue