commit ba2c0cc5598aaaf848d357ff15da94bcc03b411f
parent fa73540dcc59da8c14fd6a1479c7bc59723b1d54
Author: Marcello Stanisci <marcello.stanisci@inria.fr>
Date: Wed, 22 Jun 2016 20:48:00 +0200
NULL-terminating instances array
Diffstat:
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
@@ -47,9 +47,10 @@
#define UNIX_BACKLOG 500
/**
- * Array of all merchants instances known by this backend
+ * NULL-terminated array of all merchants instances known
+ * by this backend
*/
-struct MerchantInstance *instances;
+struct MerchantInstance **instances;
/**
* Our wire format details in JSON format (with salt).
@@ -539,11 +540,11 @@ instances_iterator_cb (void *cls,
instance_wiresection);
GNUNET_free (instance_wiresection);
+ GNUNET_array_append (instances, iic->current_index, mi);
/**
* TODO
*
* place data in global place
- *
*/
}
@@ -568,6 +569,7 @@ iterate_instances (const struct GNUNET_CONFIGURATION_Handle *config,
"libtaler_plugin_wire_%s",
allowed);
iic = GNUNET_new (struct IterateInstancesCls);
+ iic->current_index = 0;
iic->config = config;
iic->default_instance = GNUNET_NO;
iic->plugin = GNUNET_PLUGIN_load (lib_name,
@@ -601,6 +603,7 @@ iterate_instances (const struct GNUNET_CONFIGURATION_Handle *config,
GNUNET_PLUGIN_unload (lib_name,
iic->plugin);
GNUNET_free (lib_name);
+ GNUNET_array_append (instances, iic->current_index, NULL);
GNUNET_free (iic);
return GNUNET_OK;
}
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h
@@ -45,6 +45,13 @@ struct IterateInstancesCls {
const struct GNUNET_CONFIGURATION_Handle *config;
/**
+ * Current index in the global array of #MerchantInstance
+ * types. Used by the callback in order to properly place
+ * the instance it is parsing
+ */
+ unsigned int current_index;
+
+ /**
* Flag indicating whether config contains a default instance
*/
unsigned int default_instance;