smtk-import reuse pre-existent code and fix leak

Use update_event_name() for bookmarks merge and free temp string.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
This commit is contained in:
Salvador Cuñat 2017-04-12 21:54:47 +02:00 committed by Dirk Hohndel
parent 329a6bc075
commit 75007aa4ef

View file

@ -687,15 +687,15 @@ static void smtk_parse_bookmarks(MdbHandle *mdb, struct dive *d, char *dive_idx)
time = lrint(strtod(col[4]->bind_ptr, NULL) * 60);
tmp = strdup(col[2]->bind_ptr);
ev = find_bookmark(d->dc.events, time);
if (ev != NULL) {
memset(&ev->name, 0, strlen(tmp) + 1);
memcpy(ev->name, tmp, strlen(tmp));
} else
if (ev)
update_event_name(d, ev, tmp);
else
if (!add_event(&d->dc, time, SAMPLE_EVENT_BOOKMARK, 0, 0, tmp))
report_error("[smtk-import] Error - Couldn't add bookmark, dive %d, Name = %s",
d->number, tmp);
}
}
free(tmp);
smtk_free(bound_values, table->num_cols);
mdb_free_tabledef(table);
}