diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-02-13 07:02:26 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-13 14:27:34 -0800 |
commit | d8146445fcf962e456af91c592536481fdc2753f (patch) | |
tree | ccb208f025ac127e86aee6126047ff5e51e6740c /divesite.c | |
parent | d2baa3631270f8b9bcd612f971d269f5d06fca79 (diff) | |
download | subsurface-d8146445fcf962e456af91c592536481fdc2753f.tar.gz |
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>
Diffstat (limited to 'divesite.c')
-rw-r--r-- | divesite.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/divesite.c b/divesite.c index 4339a658a..492ba9d82 100644 --- a/divesite.c +++ b/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) { |