core: convert picture.c to C++

The last C-file in core. Yippie.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-04 17:31:04 +02:00 committed by bstoeger
parent 7d3977481a
commit 9065bf8622
6 changed files with 9 additions and 10 deletions

View file

@ -65,7 +65,7 @@ SOURCES += subsurface-mobile-main.cpp \
core/load-git.cpp \
core/parse-xml.cpp \
core/parse.cpp \
core/picture.c \
core/picture.cpp \
core/pictureobj.cpp \
core/sample.cpp \
core/import-suunto.cpp \

View file

@ -136,7 +136,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
parse-xml.cpp
parse.cpp
parse.h
picture.c
picture.cpp
picture.h
pictureobj.cpp
pictureobj.h

View file

@ -1773,7 +1773,7 @@ static int parse_picture_entry(struct git_parser_state *state, const git_tree_en
/* add_picture took ownership of the data -
* clear out our copy just to be sure. */
state->active_pic = empty_picture;
state->active_pic = picture();
return 0;
}

View file

@ -71,7 +71,7 @@ void event_end(struct parser_state *state)
{
struct divecomputer *dc = get_dc(state);
if (state->cur_event.type == 123) {
struct picture pic = empty_picture;
struct picture pic;
pic.filename = strdup(state->cur_event.name);
/* theoretically this could fail - but we didn't support multi year offsets */
pic.offset.seconds = state->cur_event.time.seconds;
@ -313,7 +313,7 @@ void picture_end(struct parser_state *state)
{
add_picture(&state->cur_dive->pictures, state->cur_picture);
/* dive_add_picture took ownership, we can just clear out copy of the data */
state->cur_picture = empty_picture;
state->cur_picture = picture();
}
cylinder_t *cylinder_start(struct parser_state *state)

View file

@ -139,7 +139,7 @@ struct picture *create_picture(const char *filename, timestamp_t shift_time, boo
if (!match_all && !dive_check_picture_time(*dive, timestamp))
return NULL;
struct picture *picture = malloc(sizeof(struct picture));
struct picture *picture = (struct picture *)malloc(sizeof(struct picture));
picture->filename = strdup(filename);
picture->offset.seconds = metadata.timestamp - (*dive)->when + shift_time;
picture->location = metadata.location;

View file

@ -13,11 +13,10 @@ extern "C" {
struct dive;
struct picture {
char *filename;
offset_t offset;
location_t location;
char *filename = nullptr;
offset_t offset = { 0 };
location_t location = { { 0 }, { 0 } };
};
static const struct picture empty_picture = { NULL, { 0 }, { { 0 }, { 0 } } };
/* loop through all pictures of a dive */
#define FOR_EACH_PICTURE(_dive) \