diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-07-05 22:29:00 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-07-05 22:29:00 +0000 |
commit | 22be7cccf0e0c83db811d58b7951172c27c93f3e (patch) | |
tree | 3b966b014f5089264322f669c14341c4503055ba /src/testbed/testbed_api_hosts.c | |
parent | 8c37520f379651afd01fbb65f66fca17d0cf4ce3 (diff) | |
download | gnunet-22be7cccf0e0c83db811d58b7951172c27c93f3e.tar.gz gnunet-22be7cccf0e0c83db811d58b7951172c27c93f3e.zip |
fixes
Diffstat (limited to 'src/testbed/testbed_api_hosts.c')
-rw-r--r-- | src/testbed/testbed_api_hosts.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index 4d9fb2e61..326a64924 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -232,7 +232,7 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, | |||
232 | { | 232 | { |
233 | struct GNUNET_TESTBED_Host *host; | 233 | struct GNUNET_TESTBED_Host *host; |
234 | 234 | ||
235 | if ((id < host_list_size) && (NULL != host_list[host_list_size])) | 235 | if ((id < host_list_size) && (NULL != host_list[id])) |
236 | { | 236 | { |
237 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n"); | 237 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n"); |
238 | return NULL; | 238 | return NULL; |
@@ -242,12 +242,16 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, | |||
242 | host->username = username; | 242 | host->username = username; |
243 | host->id = id; | 243 | host->id = id; |
244 | host->port = (0 == port) ? 22 : port; | 244 | host->port = (0 == port) ? 22 : port; |
245 | if (id < host_list_size) | 245 | if (id >= host_list_size) |
246 | { | 246 | { |
247 | host_list_size += HOST_LIST_GROW_STEP; | 247 | host_list_size += HOST_LIST_GROW_STEP; |
248 | host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host) | 248 | host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host) |
249 | * host_list_size); | 249 | * host_list_size); |
250 | (void) memset(&host_list[host_list_size - HOST_LIST_GROW_STEP], | ||
251 | 0, sizeof (struct GNUNET_TESTBED_Host) * host_list_size); | ||
250 | } | 252 | } |
253 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
254 | "Adding host with id: %u\n", host->id); | ||
251 | host_list[id] = host; | 255 | host_list[id] = host; |
252 | return host; | 256 | return host; |
253 | } | 257 | } |
@@ -316,7 +320,8 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
316 | } | 320 | } |
317 | for (id = 0; id < HOST_LIST_GROW_STEP; id++) | 321 | for (id = 0; id < HOST_LIST_GROW_STEP; id++) |
318 | { | 322 | { |
319 | if ((host->id + id >= host_list_size) || (NULL != host_list[host->id + id])) | 323 | if (((host->id + id) >= host_list_size) || |
324 | (NULL != host_list[host->id + id])) | ||
320 | break; | 325 | break; |
321 | } | 326 | } |
322 | if (HOST_LIST_GROW_STEP == id) | 327 | if (HOST_LIST_GROW_STEP == id) |