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>
This commit is contained in:
Tomaz Canabrava 2014-07-29 23:03:32 -03:00 committed by Dirk Hohndel
parent 1e6986d870
commit 3b9bceacb6
6 changed files with 32 additions and 8 deletions

17
dive.c
View file

@ -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 */