summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-07-29 23:03:32 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-30 12:52:31 -0700
commit3b9bceacb6efcd3e97c95077a2295c931c834514 (patch)
treec40ae2d7529f5fd6aab9d9041c785202fe0c61a0 /dive.c
parent1e6986d87010a636d151f77b3da2a40d52a95178 (diff)
downloadsubsurface-3b9bceacb6efcd3e97c95077a2295c931c834514.tar.gz
Implement the functionality of remove_picture.
Added the remove_picture functionality, with code shamelessy stolen from remove_event, and hoock it up with the interface. Fixes #650 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/dive.c b/dive.c
index 139afe23e..dd847c261 100644
--- a/dive.c
+++ b/dive.c
@@ -2489,9 +2489,22 @@ void dive_set_geodata_from_picture(struct dive *d, struct picture *pic)
}
}
-void dive_remove_picture(struct dive *d, struct picture *p)
+static void picture_free( struct picture *p){
+ if (!p)
+ return;
+ free( p->filename );
+ free( p );
+}
+void dive_remove_picture(struct picture *p)
{
-
+ struct picture **ep = &current_dive->picture_list;
+ while (ep && !same_string((*ep)->filename, p->filename))
+ ep = &(*ep)->next;
+ if (ep) {
+ struct picture *temp = (*ep)->next;
+ picture_free(*ep);
+ *ep = temp;
+ }
}
/* this always acts on the current divecomputer of the current dive */