Paul Cercueil / libiio

Dependencies:   libserialport libxml2

Revision:
4:ad69b39bf124
Parent:
3:d147beabba0e
--- a/context.c	Mon Jan 30 13:00:39 2017 +0000
+++ b/context.c	Mon Jun 26 14:30:10 2017 +0000
@@ -71,7 +71,7 @@
 			return NULL;
 		}
 
-		devices = malloc(ctx->nb_devices * sizeof(*devices));
+		devices = calloc(ctx->nb_devices, sizeof(*devices));
 		if (!devices)
 			goto err_free_devices_len;
 
@@ -119,7 +119,7 @@
 	return str;
 
 err_free_devices:
-	while (i--)
+	for (i = 0; i < ctx->nb_devices; i++)
 		free(devices[i]);
 	free(devices);
 err_free_devices_len:
@@ -223,6 +223,9 @@
 			}
 		}
 	} while (found);
+
+	for (i = 0; i < dev->nb_channels; i++)
+		dev->channels[i]->number = i;
 }
 
 int iio_context_init(struct iio_context *ctx)