[PATCH] Update to the latest libdivecomputer api.
Linus Torvalds
torvalds at linux-foundation.org
Mon Aug 27 15:24:45 PDT 2012
I did this differently, but didn't check the end result with my dive
computer yet. I pushed it out as obvious, though.
Linus
On Mon, Aug 27, 2012 at 2:24 PM, Jef Driesen <jefdriesen at telenet.be> wrote:
> A library context object is now required before creating any other
> library objects. This patch implements just the bare minimum to make
> subsurface compile again. None of the new features are used yet.
>
> Signed-off-by: Jef Driesen <jefdriesen at telenet.be>
> ---
> libdivecomputer.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/libdivecomputer.c b/libdivecomputer.c
> index e362d1d..a643b4d 100644
> --- a/libdivecomputer.c
> +++ b/libdivecomputer.c
> @@ -305,13 +305,6 @@ static dc_status_t import_device_data(dc_device_t *device, device_data_t *device
> return dc_device_foreach(device, dive_cb, devicedata);
> }
>
> -static dc_status_t device_open(const char *devname,
> - dc_descriptor_t *descriptor,
> - dc_device_t **device)
> -{
> - return dc_device_open(device, descriptor, devname);
> -}
> -
>
> static void event_cb(dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
> {
> @@ -353,13 +346,21 @@ cancel_cb(void *userdata)
>
> static const char *do_libdivecomputer_import(device_data_t *data)
> {
> + dc_context_t *context = NULL;
> dc_device_t *device = NULL;
> dc_status_t rc;
>
> + rc = dc_context_new (&context);
> + if (rc != DC_STATUS_SUCCESS) {
> + return "Unable to create a context.";
> + }
> +
> import_dive_number = 0;
> - rc = device_open(data->devname, data->descriptor, &device);
> - if (rc != DC_STATUS_SUCCESS)
> + rc = dc_device_open(&device, context, data->descriptor, data->devname);
> + if (rc != DC_STATUS_SUCCESS) {
> + dc_context_free (context);
> return "Unable to open %s %s (%s)";
> + }
> data->device = device;
>
> // Register the event handler.
> @@ -367,6 +368,7 @@ static const char *do_libdivecomputer_import(device_data_t *data)
> rc = dc_device_set_events(device, events, event_cb, data);
> if (rc != DC_STATUS_SUCCESS) {
> dc_device_close(device);
> + dc_context_free (context);
> return "Error registering the event handler.";
> }
>
> @@ -374,16 +376,19 @@ static const char *do_libdivecomputer_import(device_data_t *data)
> rc = dc_device_set_cancel(device, cancel_cb, data);
> if (rc != DC_STATUS_SUCCESS) {
> dc_device_close(device);
> + dc_context_free (context);
> return "Error registering the cancellation handler.";
> }
>
> rc = import_device_data(device, data);
> if (rc != DC_STATUS_SUCCESS) {
> dc_device_close(device);
> + dc_context_free (context);
> return "Dive data import error";
> }
>
> dc_device_close(device);
> + dc_context_free (context);
> return NULL;
> }
>
> --
> 1.7.9.5
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
More information about the subsurface
mailing list