aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-05 15:54:47 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-05 15:54:47 +0100
commit29be1a71b26bed8f6b0317cc4ad12195edd6569f (patch)
treea45b210c99852e4689de1ef8c1b31e01ca37db4e
parent6640e3beca224341f82216442c8e2d417199836f (diff)
downloadgnunet-29be1a71b26bed8f6b0317cc4ad12195edd6569f.tar.gz
gnunet-29be1a71b26bed8f6b0317cc4ad12195edd6569f.zip
indentation, comment and style fixes, no semantic changes
-rw-r--r--src/fs/fs_directory.c78
-rw-r--r--src/fs/fs_download.c108
-rw-r--r--src/fs/fs_search.c7
-rw-r--r--src/fs/fs_tree.c6
-rw-r--r--src/fs/fs_uri.c22
5 files changed, 149 insertions, 72 deletions
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c
index a18a903be..514eb64b3 100644
--- a/src/fs/fs_directory.c
+++ b/src/fs/fs_directory.c
@@ -170,13 +170,14 @@ find_full_data (void *cls, const char *plugin_name,
170 * @param data pointer to the beginning of the directory 170 * @param data pointer to the beginning of the directory
171 * @param offset offset of data in the directory 171 * @param offset offset of data in the directory
172 * @param dep function to call on each entry 172 * @param dep function to call on each entry
173 * @param dep_cls closure for dep 173 * @param dep_cls closure for @a dep
174 * @return GNUNET_OK if this could be a block in a directory, 174 * @return #GNUNET_OK if this could be a block in a directory,
175 * GNUNET_NO if this could be part of a directory (but not 100% OK) 175 * #GNUNET_NO if this could be part of a directory (but not 100% OK)
176 * GNUNET_SYSERR if 'data' does not represent a directory 176 * #GNUNET_SYSERR if @a data does not represent a directory
177 */ 177 */
178int 178int
179GNUNET_FS_directory_list_contents (size_t size, const void *data, 179GNUNET_FS_directory_list_contents (size_t size,
180 const void *data,
180 uint64_t offset, 181 uint64_t offset,
181 GNUNET_FS_DirectoryEntryProcessor dep, 182 GNUNET_FS_DirectoryEntryProcessor dep,
182 void *dep_cls) 183 void *dep_cls)
@@ -194,12 +195,16 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
194 195
195 if ((offset == 0) && 196 if ((offset == 0) &&
196 ((size < 8 + sizeof (uint32_t)) || 197 ((size < 8 + sizeof (uint32_t)) ||
197 (0 != memcmp (cdata, GNUNET_FS_DIRECTORY_MAGIC, 8)))) 198 (0 != memcmp (cdata,
199 GNUNET_FS_DIRECTORY_MAGIC,
200 8))))
198 return GNUNET_SYSERR; 201 return GNUNET_SYSERR;
199 pos = offset; 202 pos = offset;
200 if (offset == 0) 203 if (offset == 0)
201 { 204 {
202 GNUNET_memcpy (&mdSize, &cdata[8], sizeof (uint32_t)); 205 GNUNET_memcpy (&mdSize,
206 &cdata[8],
207 sizeof (uint32_t));
203 mdSize = ntohl (mdSize); 208 mdSize = ntohl (mdSize);
204 if (mdSize > size - 8 - sizeof (uint32_t)) 209 if (mdSize > size - 8 - sizeof (uint32_t))
205 { 210 {
@@ -215,7 +220,12 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
215 GNUNET_break (0); 220 GNUNET_break (0);
216 return GNUNET_SYSERR; /* malformed ! */ 221 return GNUNET_SYSERR; /* malformed ! */
217 } 222 }
218 dep (dep_cls, NULL, NULL, md, 0, NULL); 223 dep (dep_cls,
224 NULL,
225 NULL,
226 md,
227 0,
228 NULL);
219 GNUNET_CONTAINER_meta_data_destroy (md); 229 GNUNET_CONTAINER_meta_data_destroy (md);
220 pos = 8 + sizeof (uint32_t) + mdSize; 230 pos = 8 + sizeof (uint32_t) + mdSize;
221 } 231 }
@@ -247,7 +257,7 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
247 257
248 uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg); 258 uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg);
249 pos = epos + 1; 259 pos = epos + 1;
250 if (uri == NULL) 260 if (NULL == uri)
251 { 261 {
252 GNUNET_free (emsg); 262 GNUNET_free (emsg);
253 pos--; /* go back to '\0' to force going to next alignment */ 263 pos--; /* go back to '\0' to force going to next alignment */
@@ -260,7 +270,9 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
260 return GNUNET_NO; /* illegal in directory! */ 270 return GNUNET_NO; /* illegal in directory! */
261 } 271 }
262 272
263 GNUNET_memcpy (&mdSize, &cdata[pos], sizeof (uint32_t)); 273 GNUNET_memcpy (&mdSize,
274 &cdata[pos],
275 sizeof (uint32_t));
264 mdSize = ntohl (mdSize); 276 mdSize = ntohl (mdSize);
265 pos += sizeof (uint32_t); 277 pos += sizeof (uint32_t);
266 if (pos + mdSize > size) 278 if (pos + mdSize > size)
@@ -269,8 +281,9 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
269 return GNUNET_NO; /* malformed - or partial download */ 281 return GNUNET_NO; /* malformed - or partial download */
270 } 282 }
271 283
272 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], mdSize); 284 md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos],
273 if (md == NULL) 285 mdSize);
286 if (NULL == md)
274 { 287 {
275 GNUNET_FS_uri_destroy (uri); 288 GNUNET_FS_uri_destroy (uri);
276 GNUNET_break (0); 289 GNUNET_break (0);
@@ -282,10 +295,17 @@ GNUNET_FS_directory_list_contents (size_t size, const void *data,
282 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME); 295 EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME);
283 full_data.size = 0; 296 full_data.size = 0;
284 full_data.data = NULL; 297 full_data.data = NULL;
285 GNUNET_CONTAINER_meta_data_iterate (md, &find_full_data, &full_data); 298 GNUNET_CONTAINER_meta_data_iterate (md,
286 if (dep != NULL) 299 &find_full_data,
300 &full_data);
301 if (NULL != dep)
287 { 302 {
288 dep (dep_cls, filename, uri, md, full_data.size, full_data.data); 303 dep (dep_cls,
304 filename,
305 uri,
306 md,
307 full_data.size,
308 full_data.data);
289 } 309 }
290 GNUNET_free_non_null (full_data.data); 310 GNUNET_free_non_null (full_data.data);
291 GNUNET_free_non_null (filename); 311 GNUNET_free_non_null (filename);
@@ -548,11 +568,12 @@ block_align (size_t start, unsigned int count, const size_t * sizes,
548 * @param bld directory to finish 568 * @param bld directory to finish
549 * @param rsize set to the number of bytes needed 569 * @param rsize set to the number of bytes needed
550 * @param rdata set to the encoded directory 570 * @param rdata set to the encoded directory
551 * @return GNUNET_OK on success 571 * @return #GNUNET_OK on success
552 */ 572 */
553int 573int
554GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld, 574GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
555 size_t * rsize, void **rdata) 575 size_t * rsize,
576 void **rdata)
556{ 577{
557 char *data; 578 char *data;
558 char *sptr; 579 char *sptr;
@@ -575,9 +596,12 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
575 bes = NULL; 596 bes = NULL;
576 if (0 < bld->count) 597 if (0 < bld->count)
577 { 598 {
578 sizes = GNUNET_malloc (bld->count * sizeof (size_t)); 599 sizes = GNUNET_new_array (bld->count,
579 perm = GNUNET_malloc (bld->count * sizeof (unsigned int)); 600 size_t);
580 bes = GNUNET_malloc (bld->count * sizeof (struct BuilderEntry *)); 601 perm = GNUNET_new_array (bld->count,
602 unsigned int);
603 bes = GNUNET_new_array (bld->count,
604 struct BuilderEntry *);
581 pos = bld->head; 605 pos = bld->head;
582 for (i = 0; i < bld->count; i++) 606 for (i = 0; i < bld->count; i++)
583 { 607 {
@@ -599,7 +623,8 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
599 data = GNUNET_malloc_large (size); 623 data = GNUNET_malloc_large (size);
600 if (data == NULL) 624 if (data == NULL)
601 { 625 {
602 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "malloc"); 626 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
627 "malloc");
603 *rsize = 0; 628 *rsize = 0;
604 *rdata = NULL; 629 *rdata = NULL;
605 GNUNET_free_non_null (sizes); 630 GNUNET_free_non_null (sizes);
@@ -608,17 +633,22 @@ GNUNET_FS_directory_builder_finish (struct GNUNET_FS_DirectoryBuilder *bld,
608 return GNUNET_SYSERR; 633 return GNUNET_SYSERR;
609 } 634 }
610 *rdata = data; 635 *rdata = data;
611 GNUNET_memcpy (data, GNUNET_DIRECTORY_MAGIC, strlen (GNUNET_DIRECTORY_MAGIC)); 636 GNUNET_memcpy (data,
637 GNUNET_DIRECTORY_MAGIC,
638 strlen (GNUNET_DIRECTORY_MAGIC));
612 off = strlen (GNUNET_DIRECTORY_MAGIC); 639 off = strlen (GNUNET_DIRECTORY_MAGIC);
613 640
614 sptr = &data[off + sizeof (uint32_t)]; 641 sptr = &data[off + sizeof (uint32_t)];
615 ret = 642 ret =
616 GNUNET_CONTAINER_meta_data_serialize (bld->meta, &sptr, 643 GNUNET_CONTAINER_meta_data_serialize (bld->meta,
644 &sptr,
617 size - off - sizeof (uint32_t), 645 size - off - sizeof (uint32_t),
618 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 646 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
619 GNUNET_assert (ret != -1); 647 GNUNET_assert (ret != -1);
620 big = htonl (ret); 648 big = htonl (ret);
621 GNUNET_memcpy (&data[off], &big, sizeof (uint32_t)); 649 GNUNET_memcpy (&data[off],
650 &big,
651 sizeof (uint32_t));
622 off += sizeof (uint32_t) + ret; 652 off += sizeof (uint32_t) + ret;
623 for (j = 0; j < bld->count; j++) 653 for (j = 0; j < bld->count; j++)
624 { 654 {
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 0789162bf..ed24a164a 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -37,14 +37,14 @@ static int
37is_recursive_download (struct GNUNET_FS_DownloadContext *dc) 37is_recursive_download (struct GNUNET_FS_DownloadContext *dc)
38{ 38{
39 return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) && 39 return (0 != (dc->options & GNUNET_FS_DOWNLOAD_OPTION_RECURSIVE)) &&
40 ((GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) || 40 ( (GNUNET_YES == GNUNET_FS_meta_data_test_for_directory (dc->meta)) ||
41 ((NULL == dc->meta) && 41 ( (NULL == dc->meta) &&
42 ((NULL == dc->filename) || 42 ( (NULL == dc->filename) ||
43 ((strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) && 43 ( (strlen (dc->filename) >= strlen (GNUNET_FS_DIRECTORY_EXT)) &&
44 (NULL != 44 (NULL !=
45 strstr (dc->filename + strlen (dc->filename) - 45 strstr (dc->filename + strlen (dc->filename) -
46 strlen (GNUNET_FS_DIRECTORY_EXT), 46 strlen (GNUNET_FS_DIRECTORY_EXT),
47 GNUNET_FS_DIRECTORY_EXT)))))); 47 GNUNET_FS_DIRECTORY_EXT)) ) ) ) );
48} 48}
49 49
50 50
@@ -278,10 +278,12 @@ try_reconnect (struct GNUNET_FS_DownloadContext *dc);
278 * @param data contents of the file (or NULL if they were not inlined) 278 * @param data contents of the file (or NULL if they were not inlined)
279 */ 279 */
280static void 280static void
281trigger_recursive_download (void *cls, const char *filename, 281trigger_recursive_download (void *cls,
282 const char *filename,
282 const struct GNUNET_FS_Uri *uri, 283 const struct GNUNET_FS_Uri *uri,
283 const struct GNUNET_CONTAINER_MetaData *meta, 284 const struct GNUNET_CONTAINER_MetaData *meta,
284 size_t length, const void *data); 285 size_t length,
286 const void *data);
285 287
286 288
287/** 289/**
@@ -304,24 +306,28 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
304 if (size64 != (uint64_t) size) 306 if (size64 != (uint64_t) size)
305 { 307 {
306 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 308 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
307 _ 309 _("Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n"));
308 ("Recursive downloads of directories larger than 4 GB are not supported on 32-bit systems\n"));
309 return; 310 return;
310 } 311 }
311 if (NULL != dc->filename) 312 if (NULL != dc->filename)
312 { 313 {
313 h = GNUNET_DISK_file_open (dc->filename, GNUNET_DISK_OPEN_READ, 314 h = GNUNET_DISK_file_open (dc->filename,
315 GNUNET_DISK_OPEN_READ,
314 GNUNET_DISK_PERM_NONE); 316 GNUNET_DISK_PERM_NONE);
315 } 317 }
316 else 318 else
317 { 319 {
318 GNUNET_assert (NULL != dc->temp_filename); 320 GNUNET_assert (NULL != dc->temp_filename);
319 h = GNUNET_DISK_file_open (dc->temp_filename, GNUNET_DISK_OPEN_READ, 321 h = GNUNET_DISK_file_open (dc->temp_filename,
322 GNUNET_DISK_OPEN_READ,
320 GNUNET_DISK_PERM_NONE); 323 GNUNET_DISK_PERM_NONE);
321 } 324 }
322 if (NULL == h) 325 if (NULL == h)
323 return; /* oops */ 326 return; /* oops */
324 data = GNUNET_DISK_file_map (h, &m, GNUNET_DISK_MAP_TYPE_READ, size); 327 data = GNUNET_DISK_file_map (h,
328 &m,
329 GNUNET_DISK_MAP_TYPE_READ,
330 size);
325 if (NULL == data) 331 if (NULL == data)
326 { 332 {
327 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 333 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -329,15 +335,25 @@ full_recursive_download (struct GNUNET_FS_DownloadContext *dc)
329 } 335 }
330 else 336 else
331 { 337 {
332 GNUNET_FS_directory_list_contents (size, data, 0, 338 if (GNUNET_OK !=
333 &trigger_recursive_download, dc); 339 GNUNET_FS_directory_list_contents (size,
340 data,
341 0,
342 &trigger_recursive_download,
343 dc))
344 {
345 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
346 _("Failed to access full directroy contents of `%s' for recursive download\n"),
347 dc->filename);
348 }
334 GNUNET_DISK_file_unmap (m); 349 GNUNET_DISK_file_unmap (m);
335 } 350 }
336 GNUNET_DISK_file_close (h); 351 GNUNET_DISK_file_close (h);
337 if (NULL == dc->filename) 352 if (NULL == dc->filename)
338 { 353 {
339 if (0 != UNLINK (dc->temp_filename)) 354 if (0 != UNLINK (dc->temp_filename))
340 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", 355 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
356 "unlink",
341 dc->temp_filename); 357 dc->temp_filename);
342 GNUNET_free (dc->temp_filename); 358 GNUNET_free (dc->temp_filename);
343 dc->temp_filename = NULL; 359 dc->temp_filename = NULL;
@@ -362,14 +378,17 @@ check_completed (struct GNUNET_FS_DownloadContext *dc)
362 struct GNUNET_FS_DownloadContext *pos; 378 struct GNUNET_FS_DownloadContext *pos;
363 379
364 /* first, check if we need to download children */ 380 /* first, check if we need to download children */
365 if ((NULL == dc->child_head) && (is_recursive_download (dc))) 381 if ( (NULL == dc->child_head) &&
382 (is_recursive_download (dc)) )
366 full_recursive_download (dc); 383 full_recursive_download (dc);
367 /* then, check if children are done already */ 384 /* then, check if children are done already */
368 for (pos = dc->child_head; NULL != pos; pos = pos->next) 385 for (pos = dc->child_head; NULL != pos; pos = pos->next)
369 { 386 {
370 if ((pos->emsg == NULL) && (pos->completed < pos->length)) 387 if ( (NULL == pos->emsg) &&
388 (pos->completed < pos->length) )
371 return; /* not done yet */ 389 return; /* not done yet */
372 if ((pos->child_head != NULL) && (pos->has_finished != GNUNET_YES)) 390 if ( (NULL != pos->child_head) &&
391 (pos->has_finished != GNUNET_YES) )
373 return; /* not transitively done yet */ 392 return; /* not transitively done yet */
374 } 393 }
375 /* All of our children are done, so mark this download done */ 394 /* All of our children are done, so mark this download done */
@@ -471,7 +490,11 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
471 } 490 }
472 GNUNET_CRYPTO_hash (&data[dr->offset], dlen, &in_chk.key); 491 GNUNET_CRYPTO_hash (&data[dr->offset], dlen, &in_chk.key);
473 GNUNET_CRYPTO_hash_to_aes_key (&in_chk.key, &sk, &iv); 492 GNUNET_CRYPTO_hash_to_aes_key (&in_chk.key, &sk, &iv);
474 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&data[dr->offset], dlen, &sk, &iv, enc)) 493 if (-1 == GNUNET_CRYPTO_symmetric_encrypt (&data[dr->offset],
494 dlen,
495 &sk,
496 &iv,
497 enc))
475 { 498 {
476 GNUNET_break (0); 499 GNUNET_break (0);
477 return; 500 return;
@@ -484,7 +507,9 @@ try_match_block (struct GNUNET_FS_DownloadContext *dc,
484 dr->state = BRS_RECONSTRUCT_META_UP; 507 dr->state = BRS_RECONSTRUCT_META_UP;
485 break; 508 break;
486 case BRS_CHK_SET: 509 case BRS_CHK_SET:
487 if (0 != memcmp (&in_chk, &dr->chk, sizeof (struct ContentHashKey))) 510 if (0 != memcmp (&in_chk,
511 &dr->chk,
512 sizeof (struct ContentHashKey)))
488 { 513 {
489 /* other peer provided bogus meta data */ 514 /* other peer provided bogus meta data */
490 GNUNET_break_op (0); 515 GNUNET_break_op (0);
@@ -591,7 +616,10 @@ match_full_data (void *cls, const char *plugin_name,
591 GNUNET_break_op (0); 616 GNUNET_break_op (0);
592 return 1; /* bogus meta data */ 617 return 1; /* bogus meta data */
593 } 618 }
594 try_match_block (dc, dc->top_request, data, data_len); 619 try_match_block (dc,
620 dc->top_request,
621 data,
622 data_len);
595 return 1; 623 return 1;
596} 624}
597 625
@@ -820,10 +848,12 @@ schedule_block_download (struct GNUNET_FS_DownloadContext *dc,
820 * @param data contents of the file (or NULL if they were not inlined) 848 * @param data contents of the file (or NULL if they were not inlined)
821 */ 849 */
822static void 850static void
823trigger_recursive_download (void *cls, const char *filename, 851trigger_recursive_download (void *cls,
852 const char *filename,
824 const struct GNUNET_FS_Uri *uri, 853 const struct GNUNET_FS_Uri *uri,
825 const struct GNUNET_CONTAINER_MetaData *meta, 854 const struct GNUNET_CONTAINER_MetaData *meta,
826 size_t length, const void *data) 855 size_t length,
856 const void *data)
827{ 857{
828 struct GNUNET_FS_DownloadContext *dc = cls; 858 struct GNUNET_FS_DownloadContext *dc = cls;
829 struct GNUNET_FS_DownloadContext *cpos; 859 struct GNUNET_FS_DownloadContext *cpos;
@@ -936,9 +966,17 @@ trigger_recursive_download (void *cls, const char *filename,
936 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri), 966 (unsigned long long) GNUNET_FS_uri_chk_get_file_size (uri),
937 (unsigned int) 967 (unsigned int)
938 GNUNET_CONTAINER_meta_data_get_serialized_size (meta)); 968 GNUNET_CONTAINER_meta_data_get_serialized_size (meta));
939 GNUNET_FS_download_start (dc->h, uri, meta, full_name, temp_name, 0, 969 GNUNET_FS_download_start (dc->h,
970 uri,
971 meta,
972 full_name,
973 temp_name,
974 0,
940 GNUNET_FS_uri_chk_get_file_size (uri), 975 GNUNET_FS_uri_chk_get_file_size (uri),
941 dc->anonymity, dc->options, NULL, dc); 976 dc->anonymity,
977 dc->options,
978 NULL,
979 dc);
942 GNUNET_free_non_null (full_name); 980 GNUNET_free_non_null (full_name);
943 GNUNET_free_non_null (temp_name); 981 GNUNET_free_non_null (temp_name);
944 GNUNET_free_non_null (fn); 982 GNUNET_free_non_null (fn);
@@ -953,11 +991,9 @@ trigger_recursive_download (void *cls, const char *filename,
953void 991void
954GNUNET_FS_free_download_request_ (struct DownloadRequest *dr) 992GNUNET_FS_free_download_request_ (struct DownloadRequest *dr)
955{ 993{
956 unsigned int i;
957
958 if (NULL == dr) 994 if (NULL == dr)
959 return; 995 return;
960 for (i = 0; i < dr->num_children; i++) 996 for (unsigned int i = 0; i < dr->num_children; i++)
961 GNUNET_FS_free_download_request_ (dr->children[i]); 997 GNUNET_FS_free_download_request_ (dr->children[i]);
962 GNUNET_free_non_null (dr->children); 998 GNUNET_free_non_null (dr->children);
963 GNUNET_free (dr); 999 GNUNET_free (dr);
@@ -1509,13 +1545,17 @@ create_download_request (struct DownloadRequest *parent,
1509 GNUNET_assert (dr->num_children > 0); 1545 GNUNET_assert (dr->num_children > 0);
1510 1546
1511 dr->children = 1547 dr->children =
1512 GNUNET_malloc (dr->num_children * sizeof (struct DownloadRequest *)); 1548 GNUNET_new_array (dr->num_children,
1549 struct DownloadRequest *);
1513 for (i = 0; i < dr->num_children; i++) 1550 for (i = 0; i < dr->num_children; i++)
1514 { 1551 {
1515 dr->children[i] = 1552 dr->children[i] =
1516 create_download_request (dr, i + head_skip, depth - 1, 1553 create_download_request (dr,
1554 i + head_skip,
1555 depth - 1,
1517 dr_offset + (i + head_skip) * child_block_size, 1556 dr_offset + (i + head_skip) * child_block_size,
1518 file_start_offset, desired_length); 1557 file_start_offset,
1558 desired_length);
1519 } 1559 }
1520 return dr; 1560 return dr;
1521} 1561}
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index 3cbf2afef..e31115f39 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -1383,9 +1383,10 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
1383 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount); 1383 GNUNET_assert (0 != sc->uri->data.ksk.keywordCount);
1384 anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous (); 1384 anon = GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
1385 GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub); 1385 GNUNET_CRYPTO_ecdsa_key_get_public (anon, &anon_pub);
1386 sc->requests = 1386 sc->requests
1387 GNUNET_malloc (sizeof (struct SearchRequestEntry) * 1387 = GNUNET_new_array (sc->uri->data.ksk.keywordCount,
1388 sc->uri->data.ksk.keywordCount); 1388 struct SearchRequestEntry);
1389
1389 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++) 1390 for (i = 0; i < sc->uri->data.ksk.keywordCount; i++)
1390 { 1391 {
1391 keyword = &sc->uri->data.ksk.keywords[i][1]; 1392 keyword = &sc->uri->data.ksk.keywords[i][1];
diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c
index b3c632203..e57e4e494 100644
--- a/src/fs/fs_tree.c
+++ b/src/fs/fs_tree.c
@@ -285,9 +285,9 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size,
285 te->progress = progress; 285 te->progress = progress;
286 te->cont = cont; 286 te->cont = cont;
287 te->chk_tree_depth = GNUNET_FS_compute_depth (size); 287 te->chk_tree_depth = GNUNET_FS_compute_depth (size);
288 te->chk_tree = 288 te->chk_tree
289 GNUNET_malloc (te->chk_tree_depth * CHK_PER_INODE * 289 = GNUNET_new_array (te->chk_tree_depth * CHK_PER_INODE,
290 sizeof (struct ContentHashKey)); 290 struct ContentHashKey);
291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
292 "Created tree encoder for file with %llu bytes and depth %u\n", 292 "Created tree encoder for file with %llu bytes and depth %u\n",
293 (unsigned long long) size, 293 (unsigned long long) size,
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index fa27e6e9b..11968b750 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -309,7 +309,8 @@ uri_ksk_parse (const char *s,
309 } 309 }
310 iret = max; 310 iret = max;
311 dup = GNUNET_strdup (s); 311 dup = GNUNET_strdup (s);
312 keywords = GNUNET_malloc (max * sizeof (char *)); 312 keywords = GNUNET_new_array (max,
313 char *);
313 for (i = slen - 1; i >= (int) pos; i--) 314 for (i = slen - 1; i >= (int) pos; i--)
314 { 315 {
315 if ((s[i] == '%') && (&s[i] == strstr (&s[i], "%22"))) 316 if ((s[i] == '%') && (&s[i] == strstr (&s[i], "%22")))
@@ -937,7 +938,8 @@ GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1,
937 return NULL; 938 return NULL;
938 } 939 }
939 kc = u1->data.ksk.keywordCount; 940 kc = u1->data.ksk.keywordCount;
940 kl = GNUNET_malloc ((kc + u2->data.ksk.keywordCount) * sizeof (char *)); 941 kl = GNUNET_new_array (kc + u2->data.ksk.keywordCount,
942 char *);
941 for (i = 0; i < u1->data.ksk.keywordCount; i++) 943 for (i = 0; i < u1->data.ksk.keywordCount; i++)
942 kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]); 944 kl[i] = GNUNET_strdup (u1->data.ksk.keywords[i]);
943 for (i = 0; i < u2->data.ksk.keywordCount; i++) 945 for (i = 0; i < u2->data.ksk.keywordCount; i++)
@@ -991,8 +993,9 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri)
991 } 993 }
992 if (ret->data.ksk.keywordCount > 0) 994 if (ret->data.ksk.keywordCount > 0)
993 { 995 {
994 ret->data.ksk.keywords = 996 ret->data.ksk.keywords
995 GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *)); 997 = GNUNET_new_array (ret->data.ksk.keywordCount,
998 char *);
996 for (i = 0; i < ret->data.ksk.keywordCount; i++) 999 for (i = 0; i < ret->data.ksk.keywordCount; i++)
997 ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]); 1000 ret->data.ksk.keywords[i] = GNUNET_strdup (uri->data.ksk.keywords[i]);
998 } 1001 }
@@ -1078,7 +1081,8 @@ GNUNET_FS_uri_ksk_create (const char *keywords,
1078 *emsg = GNUNET_strdup (_("Number of double-quotes not balanced!\n")); 1081 *emsg = GNUNET_strdup (_("Number of double-quotes not balanced!\n"));
1079 return NULL; 1082 return NULL;
1080 } 1083 }
1081 keywordarr = GNUNET_malloc (num_Words * sizeof (char *)); 1084 keywordarr = GNUNET_new_array (num_Words,
1085 char *);
1082 num_Words = 0; 1086 num_Words = 0;
1083 inWord = 0; 1087 inWord = 0;
1084 pos = searchString; 1088 pos = searchString;
@@ -1151,7 +1155,8 @@ GNUNET_FS_uri_ksk_create_from_args (unsigned int argc,
1151 uri = GNUNET_new (struct GNUNET_FS_Uri); 1155 uri = GNUNET_new (struct GNUNET_FS_Uri);
1152 uri->type = GNUNET_FS_URI_KSK; 1156 uri->type = GNUNET_FS_URI_KSK;
1153 uri->data.ksk.keywordCount = argc; 1157 uri->data.ksk.keywordCount = argc;
1154 uri->data.ksk.keywords = GNUNET_malloc (argc * sizeof (char *)); 1158 uri->data.ksk.keywords = GNUNET_new_array (argc,
1159 char *);
1155 for (i = 0; i < argc; i++) 1160 for (i = 0; i < argc; i++)
1156 { 1161 {
1157 keyword = argv[i]; 1162 keyword = argv[i];
@@ -1766,8 +1771,9 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData
1766 } 1771 }
1767 /* x3 because there might be a normalized variant of every keyword, 1772 /* x3 because there might be a normalized variant of every keyword,
1768 plus theoretically one more for mime... */ 1773 plus theoretically one more for mime... */
1769 ret->data.ksk.keywords = GNUNET_malloc 1774 ret->data.ksk.keywords
1770 (sizeof (char *) * (ent + tok_keywords + paren_keywords) * 3); 1775 = GNUNET_new_array ((ent + tok_keywords + paren_keywords) * 3,
1776 char *);
1771 GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret); 1777 GNUNET_CONTAINER_meta_data_iterate (md, &gather_uri_data, ret);
1772 } 1778 }
1773 if (tok_keywords > 0) 1779 if (tok_keywords > 0)