diff --git a/Subsurface-mobile.pro b/Subsurface-mobile.pro index 8e1587a1b..3d2288476 100644 --- a/Subsurface-mobile.pro +++ b/Subsurface-mobile.pro @@ -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 \ diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index f95851f7d..4aad3ddf0 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -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 diff --git a/core/load-git.cpp b/core/load-git.cpp index 88c3f7af4..1d8ec98f9 100644 --- a/core/load-git.cpp +++ b/core/load-git.cpp @@ -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; } diff --git a/core/parse.cpp b/core/parse.cpp index d3d36b766..fd283f647 100644 --- a/core/parse.cpp +++ b/core/parse.cpp @@ -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) diff --git a/core/picture.c b/core/picture.cpp similarity index 98% rename from core/picture.c rename to core/picture.cpp index 632c3a2f5..3de5f1b35 100644 --- a/core/picture.c +++ b/core/picture.cpp @@ -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; diff --git a/core/picture.h b/core/picture.h index 042fb9bae..39f526d3a 100644 --- a/core/picture.h +++ b/core/picture.h @@ -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) \