aboutsummaryrefslogtreecommitdiffstats
path: root/core/load-git.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-11 17:41:56 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 13:58:09 -0700
commit989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c (patch)
tree006daeb578ac4d3e68044ecfc36e7e12b1604ee8 /core/load-git.c
parent282041e228d4a60ff7108fbfd1fc23caffd59ba4 (diff)
downloadsubsurface-989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c.tar.gz
media: use table instead of linked list for media
For consistency with equipment, use our table macros for pictures. Generally tables (arrays) are preferred over linked lists, because they allow random access. This is mostly copy & paste of the equipment code. Sadly, our table macros are quite messy and need some revamping. Therefore, the resulting code is likewise somewhat messy. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/load-git.c')
-rw-r--r--core/load-git.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/load-git.c b/core/load-git.c
index ec922d37b..8d3257d0b 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -34,7 +34,7 @@ struct git_parser_state {
struct divecomputer *active_dc;
struct dive *active_dive;
dive_trip_t *active_trip;
- struct picture *active_pic;
+ struct picture active_pic;
struct dive_site *active_site;
struct dive_table *table;
struct trip_table *trips;
@@ -1006,13 +1006,13 @@ static void parse_settings_divecomputerid(char *line, struct membuffer *str, str
static void parse_picture_filename(char *line, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(line);
- state->active_pic->filename = detach_cstring(str);
+ state->active_pic.filename = detach_cstring(str);
}
static void parse_picture_gps(char *line, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(str);
- parse_location(line, &state->active_pic->location);
+ parse_location(line, &state->active_pic.location);
}
static void parse_picture_hash(char *line, struct membuffer *str, struct git_parser_state *state)
@@ -1615,13 +1615,15 @@ static int parse_picture_entry(struct git_parser_state *state, const git_tree_en
if (!blob)
return report_error("Unable to read picture file");
- state->active_pic = alloc_picture();
- state->active_pic->offset.seconds = offset;
+ state->active_pic.offset.seconds = offset;
for_each_line(blob, picture_parser, state);
- dive_add_picture(state->active_dive, state->active_pic);
+ add_picture(&state->active_dive->pictures, state->active_pic);
git_blob_free(blob);
- state->active_pic = NULL;
+
+ /* add_picture took ownership of the data -
+ * clear out our copy just to be sure. */
+ state->active_pic = empty_picture;
return 0;
}