aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-03-21 14:05:06 +0000
committerBart Polot <bart@net.in.tum.de>2013-03-21 14:05:06 +0000
commite9077e888ecb1447d5094d4669063b0eb12b02d4 (patch)
treebc02fcb26748f241b54eca60534942c195b7cb92 /src
parent246da91802a5dbb88ae09132d73787930f5f7f46 (diff)
downloadgnunet-e9077e888ecb1447d5094d4669063b0eb12b02d4.tar.gz
gnunet-e9077e888ecb1447d5094d4669063b0eb12b02d4.zip
- fix app types allocation
Diffstat (limited to 'src')
-rw-r--r--src/mesh/mesh_api.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index be2ec277d..8683d7f24 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -129,7 +129,7 @@ struct GNUNET_MESH_Handle
129 * registered independently and the mapping is up to the developer of the 129 * registered independently and the mapping is up to the developer of the
130 * client application. 130 * client application.
131 */ 131 */
132 const GNUNET_MESH_ApplicationType *applications; 132 GNUNET_MESH_ApplicationType *applications;
133 133
134 /** 134 /**
135 * Double linked list of the tunnels this client is connected to, head. 135 * Double linked list of the tunnels this client is connected to, head.
@@ -1696,6 +1696,7 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
1696 const GNUNET_MESH_ApplicationType *stypes) 1696 const GNUNET_MESH_ApplicationType *stypes)
1697{ 1697{
1698 struct GNUNET_MESH_Handle *h; 1698 struct GNUNET_MESH_Handle *h;
1699 size_t size;
1699 1700
1700 LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_MESH_connect()\n"); 1701 LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_MESH_connect()\n");
1701 h = GNUNET_malloc (sizeof (struct GNUNET_MESH_Handle)); 1702 h = GNUNET_malloc (sizeof (struct GNUNET_MESH_Handle));
@@ -1711,17 +1712,22 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls,
1711 return NULL; 1712 return NULL;
1712 } 1713 }
1713 h->cls = cls; 1714 h->cls = cls;
1714 /* FIXME memdup? */
1715 h->applications = stypes;
1716 h->message_handlers = handlers; 1715 h->message_handlers = handlers;
1717 h->next_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_CLI; 1716 h->next_tid = GNUNET_MESH_LOCAL_TUNNEL_ID_CLI;
1718 h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS; 1717 h->reconnect_time = GNUNET_TIME_UNIT_MILLISECONDS;
1719 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 1718 h->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
1720 1719
1721 /* count handlers and apps, calculate size */ 1720 /* count apps */
1722 for (h->n_applications = 0; 1721 for (h->n_applications = 0;
1723 stypes && stypes[h->n_applications]; 1722 stypes && stypes[h->n_applications];
1724 h->n_applications++) ; 1723 h->n_applications++) ;
1724 if (0 < h->n_applications)
1725 {
1726 size = h->n_applications * sizeof (GNUNET_MESH_ApplicationType *);
1727 h->applications = GNUNET_malloc (size);
1728 memcpy (h->applications, stypes, size);
1729 }
1730 /* count handlers */
1725 for (h->n_handlers = 0; 1731 for (h->n_handlers = 0;
1726 handlers && handlers[h->n_handlers].type; 1732 handlers && handlers[h->n_handlers].type;
1727 h->n_handlers++) ; 1733 h->n_handlers++) ;
@@ -1806,6 +1812,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
1806 GNUNET_SCHEDULER_cancel(handle->reconnect_task); 1812 GNUNET_SCHEDULER_cancel(handle->reconnect_task);
1807 handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 1813 handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
1808 } 1814 }
1815 GNUNET_free_non_null (handle->applications);
1809 GNUNET_free (handle); 1816 GNUNET_free (handle);
1810} 1817}
1811 1818