diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-10-06 10:48:41 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-26 11:36:23 -0700 |
commit | d16d57577dae2f97e8e1a8bb33812718039ba605 (patch) | |
tree | 0357925a89d7690142a49bfc7cd7bb58c01f59e6 /core/dive.c | |
parent | 70737b9eec9e0ff799a5a95e1b714ed1822010cd (diff) | |
download | subsurface-d16d57577dae2f97e8e1a8bb33812718039ba605.tar.gz |
Core: export dive-computer freeing function
The dive-computer freeing code was local to dive.c. Implementing
the replan undo-command will need that functionality. Therefore,
export it as a global function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/dive.c b/core/dive.c index dd6edaa84..20981c48c 100644 --- a/core/dive.c +++ b/core/dive.c @@ -339,6 +339,14 @@ static void copy_pl(struct picture *sp, struct picture *dp) dp->filename = copy_string(sp->filename); } +/* The first divecomputer is embedded in the dive structure. Free its data but not + * the structure itself. For all remainding dcs in the list, free data *and* structures. */ +void free_dive_dcs(struct divecomputer *dc) +{ + free_dc_contents(dc); + STRUCTURED_LIST_FREE(struct divecomputer, dc->next, free_dc); +} + static void free_dive_structures(struct dive *d) { if (!d) @@ -350,8 +358,7 @@ static void free_dive_structures(struct dive *d) free(d->suit); /* free tags, additional dive computers, and pictures */ taglist_free(d->tag_list); - free_dc_contents(&d->dc); - STRUCTURED_LIST_FREE(struct divecomputer, d->dc.next, free_dc); + free_dive_dcs(&d->dc); STRUCTURED_LIST_FREE(struct picture, d->picture_list, free_picture); for (int i = 0; i < MAX_CYLINDERS; i++) free((void *)d->cylinder[i].type.description); |