Restructure the Uemis native download buffer code

Running under Valgrind showed a couple of silly bugs.

Worse, intentionally running into various error scenarios showed that we
could get the buffer handling in the raw parsing code to break down - we
would fail to process the correctly downloaded files.

To make it easier to get this right I restructured the code to collect the
XML buffer in a different way - this works much better and has stood up
well under testing so far.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-09-27 00:16:42 -07:00
parent 58ba24b84e
commit bd3df859bc
2 changed files with 47 additions and 31 deletions

View file

@ -1256,7 +1256,7 @@ static int fill_computer_list(GtkListStore *store)
THIS IS A HACK as we use the internal of libdivecomputer
data structures... eventually the UEMIS code needs to move
into libdivecomputer, I guess */
mydescriptor = malloc(sizeof(mydescriptor));
mydescriptor = malloc(sizeof(struct mydescriptor));
mydescriptor->vendor = "Uemis";
mydescriptor->product = "Zurich";
mydescriptor->type = DC_FAMILY_NULL;
@ -1415,7 +1415,7 @@ void import_files(GtkWidget *w, gpointer data)
static GError *setup_uemis_import(device_data_t *data)
{
GError *error = NULL;
char *buf;
char *buf = NULL;
error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress);
if (buf && strlen(buf) > 1) {