diff options
Diffstat (limited to 'src/include/gnunet_container_lib.h')
-rw-r--r-- | src/include/gnunet_container_lib.h | 326 |
1 files changed, 183 insertions, 143 deletions
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h index 3319b710b..cfc7e0842 100644 --- a/src/include/gnunet_container_lib.h +++ b/src/include/gnunet_container_lib.h | |||
@@ -62,8 +62,7 @@ struct GNUNET_CONTAINER_BloomFilter; | |||
62 | * @return GNUNET_YES if next was updated | 62 | * @return GNUNET_YES if next was updated |
63 | * GNUNET_NO if there are no more entries | 63 | * GNUNET_NO if there are no more entries |
64 | */ | 64 | */ |
65 | typedef int (*GNUNET_HashCodeIterator) (void *cls, | 65 | typedef int (*GNUNET_HashCodeIterator) (void *cls, GNUNET_HashCode * next); |
66 | GNUNET_HashCode * next); | ||
67 | 66 | ||
68 | 67 | ||
69 | /** | 68 | /** |
@@ -76,15 +75,13 @@ typedef int (*GNUNET_HashCodeIterator) (void *cls, | |||
76 | * element (number of bits set per element in the set) | 75 | * element (number of bits set per element in the set) |
77 | * @return the bloomfilter | 76 | * @return the bloomfilter |
78 | */ | 77 | */ |
79 | struct GNUNET_CONTAINER_BloomFilter * | 78 | struct GNUNET_CONTAINER_BloomFilter *GNUNET_CONTAINER_bloomfilter_load (const |
80 | GNUNET_CONTAINER_bloomfilter_load (const | 79 | char |
81 | char | 80 | *filename, |
82 | *filename, | 81 | size_t |
83 | size_t | 82 | size, |
84 | size, | 83 | unsigned |
85 | unsigned | 84 | int k); |
86 | int | ||
87 | k); | ||
88 | 85 | ||
89 | 86 | ||
90 | /** | 87 | /** |
@@ -100,15 +97,13 @@ GNUNET_CONTAINER_bloomfilter_load (const | |||
100 | * element (number of bits set per element in the set) | 97 | * element (number of bits set per element in the set) |
101 | * @return the bloomfilter | 98 | * @return the bloomfilter |
102 | */ | 99 | */ |
103 | struct GNUNET_CONTAINER_BloomFilter * | 100 | struct GNUNET_CONTAINER_BloomFilter *GNUNET_CONTAINER_bloomfilter_init (const |
104 | GNUNET_CONTAINER_bloomfilter_init (const | 101 | char |
105 | char | 102 | *data, |
106 | *data, | 103 | size_t |
107 | size_t | 104 | size, |
108 | size, | 105 | unsigned |
109 | unsigned | 106 | int k); |
110 | int | ||
111 | k); | ||
112 | 107 | ||
113 | 108 | ||
114 | /** | 109 | /** |
@@ -121,8 +116,7 @@ GNUNET_CONTAINER_bloomfilter_init (const | |||
121 | */ | 116 | */ |
122 | int GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct | 117 | int GNUNET_CONTAINER_bloomfilter_get_raw_data (const struct |
123 | GNUNET_CONTAINER_BloomFilter | 118 | GNUNET_CONTAINER_BloomFilter |
124 | *bf, char *data, | 119 | *bf, char *data, size_t size); |
125 | size_t size); | ||
126 | 120 | ||
127 | 121 | ||
128 | /** | 122 | /** |
@@ -159,8 +153,10 @@ void GNUNET_CONTAINER_bloomfilter_remove (struct GNUNET_CONTAINER_BloomFilter | |||
159 | * @param bf the filter | 153 | * @param bf the filter |
160 | * @return copy of bf | 154 | * @return copy of bf |
161 | */ | 155 | */ |
162 | struct GNUNET_CONTAINER_BloomFilter * | 156 | struct GNUNET_CONTAINER_BloomFilter *GNUNET_CONTAINER_bloomfilter_copy (const |
163 | GNUNET_CONTAINER_bloomfilter_copy (const struct GNUNET_CONTAINER_BloomFilter *bf); | 157 | struct |
158 | GNUNET_CONTAINER_BloomFilter | ||
159 | *bf); | ||
164 | 160 | ||
165 | 161 | ||
166 | 162 | ||
@@ -180,9 +176,20 @@ void GNUNET_CONTAINER_bloomfilter_free (struct GNUNET_CONTAINER_BloomFilter | |||
180 | * @param bf the filter | 176 | * @param bf the filter |
181 | * @return number of bytes used for the data of the bloom filter | 177 | * @return number of bytes used for the data of the bloom filter |
182 | */ | 178 | */ |
183 | size_t | 179 | size_t |
180 | |||
181 | |||
182 | |||
183 | |||
184 | |||
185 | |||
186 | |||
187 | |||
188 | |||
189 | |||
190 | |||
184 | GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter | 191 | GNUNET_CONTAINER_bloomfilter_get_size (const struct GNUNET_CONTAINER_BloomFilter |
185 | *bf); | 192 | *bf); |
186 | 193 | ||
187 | 194 | ||
188 | /** | 195 | /** |
@@ -218,8 +225,8 @@ int GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
218 | */ | 225 | */ |
219 | int | 226 | int |
220 | GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf, | 227 | GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf, |
221 | const struct GNUNET_CONTAINER_BloomFilter *to_or, | 228 | const struct GNUNET_CONTAINER_BloomFilter |
222 | size_t size); | 229 | *to_or, size_t size); |
223 | 230 | ||
224 | /** | 231 | /** |
225 | * Resize a bloom filter. Note that this operation | 232 | * Resize a bloom filter. Note that this operation |
@@ -250,8 +257,7 @@ struct GNUNET_CONTAINER_MetaData; | |||
250 | * | 257 | * |
251 | * @return empty meta-data container | 258 | * @return empty meta-data container |
252 | */ | 259 | */ |
253 | struct GNUNET_CONTAINER_MetaData * | 260 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_create (void); |
254 | GNUNET_CONTAINER_meta_data_create (void); | ||
255 | 261 | ||
256 | /** | 262 | /** |
257 | * Duplicate a MetaData token. | 263 | * Duplicate a MetaData token. |
@@ -259,17 +265,17 @@ GNUNET_CONTAINER_meta_data_create (void); | |||
259 | * @param md what to duplicate | 265 | * @param md what to duplicate |
260 | * @return duplicate meta-data container | 266 | * @return duplicate meta-data container |
261 | */ | 267 | */ |
262 | struct GNUNET_CONTAINER_MetaData * | 268 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_duplicate (const |
263 | GNUNET_CONTAINER_meta_data_duplicate (const struct | 269 | struct |
264 | GNUNET_CONTAINER_MetaData *md); | 270 | GNUNET_CONTAINER_MetaData |
271 | *md); | ||
265 | 272 | ||
266 | /** | 273 | /** |
267 | * Free meta data. | 274 | * Free meta data. |
268 | * | 275 | * |
269 | * @param md what to free | 276 | * @param md what to free |
270 | */ | 277 | */ |
271 | void | 278 | void GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md); |
272 | GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md); | ||
273 | 279 | ||
274 | /** | 280 | /** |
275 | * Test if two MDs are equal. We consider them equal if | 281 | * Test if two MDs are equal. We consider them equal if |
@@ -281,11 +287,11 @@ GNUNET_CONTAINER_meta_data_destroy (struct GNUNET_CONTAINER_MetaData *md); | |||
281 | * @param md2 other value to check | 287 | * @param md2 other value to check |
282 | * @return GNUNET_YES if they are equal | 288 | * @return GNUNET_YES if they are equal |
283 | */ | 289 | */ |
284 | int | 290 | int |
285 | GNUNET_CONTAINER_meta_data_test_equal (const struct | 291 | GNUNET_CONTAINER_meta_data_test_equal (const struct |
286 | GNUNET_CONTAINER_MetaData *md1, | 292 | GNUNET_CONTAINER_MetaData *md1, |
287 | const struct | 293 | const struct |
288 | GNUNET_CONTAINER_MetaData *md2); | 294 | GNUNET_CONTAINER_MetaData *md2); |
289 | 295 | ||
290 | 296 | ||
291 | /** | 297 | /** |
@@ -305,14 +311,13 @@ GNUNET_CONTAINER_meta_data_test_equal (const struct | |||
305 | * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists | 311 | * @return GNUNET_OK on success, GNUNET_SYSERR if this entry already exists |
306 | * data_mime_type and plugin_name are not considered for "exists" checks | 312 | * data_mime_type and plugin_name are not considered for "exists" checks |
307 | */ | 313 | */ |
308 | int | 314 | int |
309 | GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | 315 | GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, |
310 | const char *plugin_name, | 316 | const char *plugin_name, |
311 | enum EXTRACTOR_MetaType type, | 317 | enum EXTRACTOR_MetaType type, |
312 | enum EXTRACTOR_MetaFormat format, | 318 | enum EXTRACTOR_MetaFormat format, |
313 | const char *data_mime_type, | 319 | const char *data_mime_type, |
314 | const char *data, | 320 | const char *data, size_t data_len); |
315 | size_t data_len); | ||
316 | 321 | ||
317 | 322 | ||
318 | /** | 323 | /** |
@@ -322,9 +327,9 @@ GNUNET_CONTAINER_meta_data_insert (struct GNUNET_CONTAINER_MetaData *md, | |||
322 | * @param md metadata to extend | 327 | * @param md metadata to extend |
323 | * @param in metadata to merge | 328 | * @param in metadata to merge |
324 | */ | 329 | */ |
325 | void | 330 | void |
326 | GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, | 331 | GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, |
327 | const struct GNUNET_CONTAINER_MetaData *in); | 332 | const struct GNUNET_CONTAINER_MetaData *in); |
328 | 333 | ||
329 | 334 | ||
330 | /** | 335 | /** |
@@ -337,11 +342,10 @@ GNUNET_CONTAINER_meta_data_merge (struct GNUNET_CONTAINER_MetaData *md, | |||
337 | * @param data_len number of bytes in data | 342 | * @param data_len number of bytes in data |
338 | * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md | 343 | * @return GNUNET_OK on success, GNUNET_SYSERR if the item does not exist in md |
339 | */ | 344 | */ |
340 | int | 345 | int |
341 | GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, | 346 | GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, |
342 | enum EXTRACTOR_MetaType type, | 347 | enum EXTRACTOR_MetaType type, |
343 | const char *data, | 348 | const char *data, size_t data_len); |
344 | size_t data_len); | ||
345 | 349 | ||
346 | 350 | ||
347 | /** | 351 | /** |
@@ -349,8 +353,7 @@ GNUNET_CONTAINER_meta_data_delete (struct GNUNET_CONTAINER_MetaData *md, | |||
349 | * | 353 | * |
350 | * @param md metadata to manipulate | 354 | * @param md metadata to manipulate |
351 | */ | 355 | */ |
352 | void | 356 | void GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md); |
353 | GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md); | ||
354 | 357 | ||
355 | 358 | ||
356 | /** | 359 | /** |
@@ -359,10 +362,9 @@ GNUNET_CONTAINER_meta_data_clear (struct GNUNET_CONTAINER_MetaData *md); | |||
359 | * | 362 | * |
360 | * @param md metadata to modify | 363 | * @param md metadata to modify |
361 | */ | 364 | */ |
362 | void | 365 | void |
363 | GNUNET_CONTAINER_meta_data_add_publication_date (struct | 366 | GNUNET_CONTAINER_meta_data_add_publication_date (struct |
364 | GNUNET_CONTAINER_MetaData | 367 | GNUNET_CONTAINER_MetaData *md); |
365 | *md); | ||
366 | 368 | ||
367 | 369 | ||
368 | /** | 370 | /** |
@@ -374,9 +376,9 @@ GNUNET_CONTAINER_meta_data_add_publication_date (struct | |||
374 | * @return number of entries | 376 | * @return number of entries |
375 | */ | 377 | */ |
376 | int GNUNET_CONTAINER_meta_data_iterate (const struct | 378 | int GNUNET_CONTAINER_meta_data_iterate (const struct |
377 | GNUNET_CONTAINER_MetaData *md, | 379 | GNUNET_CONTAINER_MetaData *md, |
378 | EXTRACTOR_MetaDataProcessor | 380 | EXTRACTOR_MetaDataProcessor |
379 | iter, void *iter_cls); | 381 | iter, void *iter_cls); |
380 | 382 | ||
381 | /** | 383 | /** |
382 | * Get the first MD entry of the given type. Caller | 384 | * Get the first MD entry of the given type. Caller |
@@ -388,10 +390,9 @@ int GNUNET_CONTAINER_meta_data_iterate (const struct | |||
388 | * @param type type to look for | 390 | * @param type type to look for |
389 | * @return NULL if no entry was found | 391 | * @return NULL if no entry was found |
390 | */ | 392 | */ |
391 | char * | 393 | char *GNUNET_CONTAINER_meta_data_get_by_type (const struct |
392 | GNUNET_CONTAINER_meta_data_get_by_type (const struct | 394 | GNUNET_CONTAINER_MetaData *md, |
393 | GNUNET_CONTAINER_MetaData *md, | 395 | enum EXTRACTOR_MetaType type); |
394 | enum EXTRACTOR_MetaType type); | ||
395 | 396 | ||
396 | 397 | ||
397 | /** | 398 | /** |
@@ -405,10 +406,9 @@ GNUNET_CONTAINER_meta_data_get_by_type (const struct | |||
405 | * @return NULL if we do not have any such entry, | 406 | * @return NULL if we do not have any such entry, |
406 | * otherwise client is responsible for freeing the value! | 407 | * otherwise client is responsible for freeing the value! |
407 | */ | 408 | */ |
408 | char * | 409 | char *GNUNET_CONTAINER_meta_data_get_first_by_types (const struct |
409 | GNUNET_CONTAINER_meta_data_get_first_by_types (const struct | 410 | GNUNET_CONTAINER_MetaData |
410 | GNUNET_CONTAINER_MetaData | 411 | *md, ...); |
411 | *md, ...); | ||
412 | 412 | ||
413 | /** | 413 | /** |
414 | * Get a thumbnail from the meta-data (if present). Only matches meta | 414 | * Get a thumbnail from the meta-data (if present). Only matches meta |
@@ -419,10 +419,10 @@ GNUNET_CONTAINER_meta_data_get_first_by_types (const struct | |||
419 | * freed by the caller! | 419 | * freed by the caller! |
420 | * @return number of bytes in thumbnail, 0 if not available | 420 | * @return number of bytes in thumbnail, 0 if not available |
421 | */ | 421 | */ |
422 | size_t | 422 | size_t |
423 | GNUNET_CONTAINER_meta_data_get_thumbnail (const struct | 423 | GNUNET_CONTAINER_meta_data_get_thumbnail (const struct |
424 | GNUNET_CONTAINER_MetaData | 424 | GNUNET_CONTAINER_MetaData |
425 | *md, unsigned char **thumb); | 425 | *md, unsigned char **thumb); |
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
@@ -463,14 +463,33 @@ enum GNUNET_CONTAINER_MetaDataSerializationOptions | |||
463 | * -1 on error (typically: not enough | 463 | * -1 on error (typically: not enough |
464 | * space) | 464 | * space) |
465 | */ | 465 | */ |
466 | ssize_t | 466 | ssize_t |
467 | |||
468 | |||
469 | |||
470 | |||
471 | |||
472 | |||
473 | |||
474 | |||
475 | |||
476 | |||
477 | |||
478 | |||
479 | |||
480 | |||
481 | |||
482 | |||
483 | |||
484 | |||
485 | |||
467 | GNUNET_CONTAINER_meta_data_serialize (const struct | 486 | GNUNET_CONTAINER_meta_data_serialize (const struct |
468 | GNUNET_CONTAINER_MetaData *md, | 487 | GNUNET_CONTAINER_MetaData *md, |
469 | char **target, | 488 | char **target, |
470 | size_t max, | 489 | size_t max, |
471 | enum | 490 | enum |
472 | GNUNET_CONTAINER_MetaDataSerializationOptions | 491 | GNUNET_CONTAINER_MetaDataSerializationOptions |
473 | opt); | 492 | opt); |
474 | 493 | ||
475 | 494 | ||
476 | /** | 495 | /** |
@@ -479,10 +498,28 @@ GNUNET_CONTAINER_meta_data_serialize (const struct | |||
479 | * @param md metadata to inspect | 498 | * @param md metadata to inspect |
480 | * @return number of bytes needed for serialization, -1 on error | 499 | * @return number of bytes needed for serialization, -1 on error |
481 | */ | 500 | */ |
482 | ssize_t | 501 | ssize_t |
502 | |||
503 | |||
504 | |||
505 | |||
506 | |||
507 | |||
508 | |||
509 | |||
510 | |||
511 | |||
512 | |||
513 | |||
514 | |||
515 | |||
516 | |||
517 | |||
518 | |||
519 | |||
520 | |||
483 | GNUNET_CONTAINER_meta_data_get_serialized_size (const struct | 521 | GNUNET_CONTAINER_meta_data_get_serialized_size (const struct |
484 | GNUNET_CONTAINER_MetaData | 522 | GNUNET_CONTAINER_MetaData *md); |
485 | *md); | ||
486 | 523 | ||
487 | 524 | ||
488 | /** | 525 | /** |
@@ -493,9 +530,11 @@ GNUNET_CONTAINER_meta_data_get_serialized_size (const struct | |||
493 | * @return MD on success, NULL on error (i.e. | 530 | * @return MD on success, NULL on error (i.e. |
494 | * bad format) | 531 | * bad format) |
495 | */ | 532 | */ |
496 | struct GNUNET_CONTAINER_MetaData * | 533 | struct GNUNET_CONTAINER_MetaData *GNUNET_CONTAINER_meta_data_deserialize (const |
497 | GNUNET_CONTAINER_meta_data_deserialize (const char *input, | 534 | char |
498 | size_t size); | 535 | *input, |
536 | size_t | ||
537 | size); | ||
499 | 538 | ||
500 | 539 | ||
501 | /* ******************************* HashMap **************************** */ | 540 | /* ******************************* HashMap **************************** */ |
@@ -561,7 +600,7 @@ typedef int (*GNUNET_CONTAINER_HashMapIterator) (void *cls, | |||
561 | * @return NULL on error | 600 | * @return NULL on error |
562 | */ | 601 | */ |
563 | struct GNUNET_CONTAINER_MultiHashMap | 602 | struct GNUNET_CONTAINER_MultiHashMap |
564 | *GNUNET_CONTAINER_multihashmap_create (unsigned int len); | 603 | *GNUNET_CONTAINER_multihashmap_create (unsigned int len); |
565 | 604 | ||
566 | 605 | ||
567 | /** | 606 | /** |
@@ -571,8 +610,7 @@ struct GNUNET_CONTAINER_MultiHashMap | |||
571 | * @param map the map | 610 | * @param map the map |
572 | */ | 611 | */ |
573 | void GNUNET_CONTAINER_multihashmap_destroy (struct | 612 | void GNUNET_CONTAINER_multihashmap_destroy (struct |
574 | GNUNET_CONTAINER_MultiHashMap | 613 | GNUNET_CONTAINER_MultiHashMap *map); |
575 | *map); | ||
576 | 614 | ||
577 | 615 | ||
578 | /** | 616 | /** |
@@ -630,8 +668,7 @@ int GNUNET_CONTAINER_multihashmap_remove_all (struct | |||
630 | */ | 668 | */ |
631 | int GNUNET_CONTAINER_multihashmap_contains (const struct | 669 | int GNUNET_CONTAINER_multihashmap_contains (const struct |
632 | GNUNET_CONTAINER_MultiHashMap | 670 | GNUNET_CONTAINER_MultiHashMap |
633 | *map, | 671 | *map, const GNUNET_HashCode * key); |
634 | const GNUNET_HashCode * key); | ||
635 | 672 | ||
636 | 673 | ||
637 | /** | 674 | /** |
@@ -645,10 +682,10 @@ int GNUNET_CONTAINER_multihashmap_contains (const struct | |||
645 | * GNUNET_NO if not | 682 | * GNUNET_NO if not |
646 | */ | 683 | */ |
647 | int GNUNET_CONTAINER_multihashmap_contains_value (const struct | 684 | int GNUNET_CONTAINER_multihashmap_contains_value (const struct |
648 | GNUNET_CONTAINER_MultiHashMap | 685 | GNUNET_CONTAINER_MultiHashMap |
649 | *map, | 686 | *map, |
650 | const GNUNET_HashCode * key, | 687 | const GNUNET_HashCode * key, |
651 | const void *value); | 688 | const void *value); |
652 | 689 | ||
653 | 690 | ||
654 | /** | 691 | /** |
@@ -667,8 +704,7 @@ int GNUNET_CONTAINER_multihashmap_put (struct GNUNET_CONTAINER_MultiHashMap | |||
667 | *map, const GNUNET_HashCode * key, | 704 | *map, const GNUNET_HashCode * key, |
668 | void *value, | 705 | void *value, |
669 | enum | 706 | enum |
670 | GNUNET_CONTAINER_MultiHashMapOption | 707 | GNUNET_CONTAINER_MultiHashMapOption opt); |
671 | opt); | ||
672 | 708 | ||
673 | /** | 709 | /** |
674 | * Get the number of key-value pairs in the map. | 710 | * Get the number of key-value pairs in the map. |
@@ -886,8 +922,9 @@ struct GNUNET_CONTAINER_HeapNode; | |||
886 | * @param order how should the heap be sorted? | 922 | * @param order how should the heap be sorted? |
887 | * @return handle to the heap | 923 | * @return handle to the heap |
888 | */ | 924 | */ |
889 | struct GNUNET_CONTAINER_Heap * | 925 | struct GNUNET_CONTAINER_Heap *GNUNET_CONTAINER_heap_create (enum |
890 | GNUNET_CONTAINER_heap_create (enum GNUNET_CONTAINER_HeapOrder order); | 926 | GNUNET_CONTAINER_HeapOrder |
927 | order); | ||
891 | 928 | ||
892 | 929 | ||
893 | /** | 930 | /** |
@@ -905,8 +942,7 @@ void GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *heap); | |||
905 | * @param heap heap to inspect | 942 | * @param heap heap to inspect |
906 | * @return NULL if heap is empty | 943 | * @return NULL if heap is empty |
907 | */ | 944 | */ |
908 | void * | 945 | void *GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap); |
909 | GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap); | ||
910 | 946 | ||
911 | 947 | ||
912 | /** | 948 | /** |
@@ -926,7 +962,8 @@ GNUNET_CONTAINER_heap_get_size (const struct GNUNET_CONTAINER_Heap *heap); | |||
926 | * @return cost of the node | 962 | * @return cost of the node |
927 | */ | 963 | */ |
928 | GNUNET_CONTAINER_HeapCostType | 964 | GNUNET_CONTAINER_HeapCostType |
929 | GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode *node); | 965 | GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode |
966 | *node); | ||
930 | 967 | ||
931 | /** | 968 | /** |
932 | * Iterator for heap | 969 | * Iterator for heap |
@@ -939,9 +976,10 @@ GNUNET_CONTAINER_heap_node_get_cost (const struct GNUNET_CONTAINER_HeapNode *nod | |||
939 | * GNUNET_NO if not. | 976 | * GNUNET_NO if not. |
940 | */ | 977 | */ |
941 | typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls, | 978 | typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls, |
942 | struct GNUNET_CONTAINER_HeapNode *node, | 979 | struct GNUNET_CONTAINER_HeapNode * |
943 | void *element, | 980 | node, void *element, |
944 | GNUNET_CONTAINER_HeapCostType cost); | 981 | GNUNET_CONTAINER_HeapCostType |
982 | cost); | ||
945 | 983 | ||
946 | 984 | ||
947 | /** | 985 | /** |
@@ -953,8 +991,8 @@ typedef int (*GNUNET_CONTAINER_HeapIterator) (void *cls, | |||
953 | */ | 991 | */ |
954 | void | 992 | void |
955 | GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap, | 993 | GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap, |
956 | GNUNET_CONTAINER_HeapIterator iterator, | 994 | GNUNET_CONTAINER_HeapIterator iterator, |
957 | void *iterator_cls); | 995 | void *iterator_cls); |
958 | 996 | ||
959 | 997 | ||
960 | /** | 998 | /** |
@@ -969,9 +1007,8 @@ GNUNET_CONTAINER_heap_iterate (const struct GNUNET_CONTAINER_Heap *heap, | |||
969 | * NULL if the heap is empty. | 1007 | * NULL if the heap is empty. |
970 | * | 1008 | * |
971 | */ | 1009 | */ |
972 | void * | 1010 | void *GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, |
973 | GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, | 1011 | uint32_t max); |
974 | uint32_t max); | ||
975 | 1012 | ||
976 | 1013 | ||
977 | /** | 1014 | /** |
@@ -985,8 +1022,7 @@ GNUNET_CONTAINER_heap_get_random (struct GNUNET_CONTAINER_Heap *heap, | |||
985 | * @return data stored at the next random node in the walk; | 1022 | * @return data stored at the next random node in the walk; |
986 | * NULL if the tree is empty. | 1023 | * NULL if the tree is empty. |
987 | */ | 1024 | */ |
988 | void * | 1025 | void *GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap); |
989 | GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap); | ||
990 | 1026 | ||
991 | 1027 | ||
992 | /** | 1028 | /** |
@@ -997,10 +1033,12 @@ GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap *heap); | |||
997 | * @param cost cost for the element | 1033 | * @param cost cost for the element |
998 | * @return node for the new element | 1034 | * @return node for the new element |
999 | */ | 1035 | */ |
1000 | struct GNUNET_CONTAINER_HeapNode * | 1036 | struct GNUNET_CONTAINER_HeapNode *GNUNET_CONTAINER_heap_insert (struct |
1001 | GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, | 1037 | GNUNET_CONTAINER_Heap |
1002 | void *element, | 1038 | *heap, |
1003 | GNUNET_CONTAINER_HeapCostType cost); | 1039 | void *element, |
1040 | GNUNET_CONTAINER_HeapCostType | ||
1041 | cost); | ||
1004 | 1042 | ||
1005 | 1043 | ||
1006 | /** | 1044 | /** |
@@ -1009,8 +1047,7 @@ GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, | |||
1009 | * @param heap heap to modify | 1047 | * @param heap heap to modify |
1010 | * @return element data stored at the root node | 1048 | * @return element data stored at the root node |
1011 | */ | 1049 | */ |
1012 | void * | 1050 | void *GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap); |
1013 | GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap); | ||
1014 | 1051 | ||
1015 | 1052 | ||
1016 | /** | 1053 | /** |
@@ -1019,8 +1056,8 @@ GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *heap); | |||
1019 | * @param node node to remove | 1056 | * @param node node to remove |
1020 | * @return element data stored at the node, NULL if heap is empty | 1057 | * @return element data stored at the node, NULL if heap is empty |
1021 | */ | 1058 | */ |
1022 | void * | 1059 | void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode |
1023 | GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node); | 1060 | *node); |
1024 | 1061 | ||
1025 | 1062 | ||
1026 | /** | 1063 | /** |
@@ -1032,8 +1069,8 @@ GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_HeapNode *node); | |||
1032 | */ | 1069 | */ |
1033 | void | 1070 | void |
1034 | GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | 1071 | GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, |
1035 | struct GNUNET_CONTAINER_HeapNode *node, | 1072 | struct GNUNET_CONTAINER_HeapNode *node, |
1036 | GNUNET_CONTAINER_HeapCostType new_cost); | 1073 | GNUNET_CONTAINER_HeapCostType new_cost); |
1037 | 1074 | ||
1038 | 1075 | ||
1039 | /* ******************** Singly linked list *************** */ | 1076 | /* ******************** Singly linked list *************** */ |
@@ -1041,24 +1078,24 @@ GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *heap, | |||
1041 | /** | 1078 | /** |
1042 | * Possible ways for how data stored in the linked list | 1079 | * Possible ways for how data stored in the linked list |
1043 | * might be allocated. | 1080 | * might be allocated. |
1044 | */ | 1081 | */ |
1045 | enum GNUNET_CONTAINER_SListDisposition | 1082 | enum GNUNET_CONTAINER_SListDisposition |
1046 | { | 1083 | { |
1047 | /** | 1084 | /** |
1048 | * Single-linked list must copy the buffer. | 1085 | * Single-linked list must copy the buffer. |
1049 | */ | 1086 | */ |
1050 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0, | 1087 | GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT = 0, |
1051 | 1088 | ||
1052 | /** | 1089 | /** |
1053 | * Data is static, no need to copy or free. | 1090 | * Data is static, no need to copy or free. |
1054 | */ | 1091 | */ |
1055 | GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2, | 1092 | GNUNET_CONTAINER_SLIST_DISPOSITION_STATIC = 2, |
1056 | 1093 | ||
1057 | /** | 1094 | /** |
1058 | * Data is dynamic, do not copy but free when done. | 1095 | * Data is dynamic, do not copy but free when done. |
1059 | */ | 1096 | */ |
1060 | GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4 | 1097 | GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC = 4 |
1061 | }; | 1098 | }; |
1062 | 1099 | ||
1063 | 1100 | ||
1064 | 1101 | ||
@@ -1080,9 +1117,9 @@ struct GNUNET_CONTAINER_SList_Iterator; | |||
1080 | * @param buf payload buffer | 1117 | * @param buf payload buffer |
1081 | * @param len length of the buffer | 1118 | * @param len length of the buffer |
1082 | */ | 1119 | */ |
1083 | void GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l, | 1120 | void GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l, |
1084 | enum GNUNET_CONTAINER_SListDisposition disp, | 1121 | enum GNUNET_CONTAINER_SListDisposition disp, |
1085 | const void *buf, size_t len); | 1122 | const void *buf, size_t len); |
1086 | 1123 | ||
1087 | 1124 | ||
1088 | /** | 1125 | /** |
@@ -1093,8 +1130,8 @@ void GNUNET_CONTAINER_slist_add (struct GNUNET_CONTAINER_SList *l, | |||
1093 | * @param len length of the buffer | 1130 | * @param len length of the buffer |
1094 | */ | 1131 | */ |
1095 | void GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l, | 1132 | void GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l, |
1096 | enum GNUNET_CONTAINER_SListDisposition disp, | 1133 | enum GNUNET_CONTAINER_SListDisposition |
1097 | const void *buf, size_t len); | 1134 | disp, const void *buf, size_t len); |
1098 | 1135 | ||
1099 | 1136 | ||
1100 | /** | 1137 | /** |
@@ -1103,7 +1140,8 @@ void GNUNET_CONTAINER_slist_add_end (struct GNUNET_CONTAINER_SList *l, | |||
1103 | * @param src source | 1140 | * @param src source |
1104 | */ | 1141 | */ |
1105 | void | 1142 | void |
1106 | GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, struct GNUNET_CONTAINER_SList *src); | 1143 | GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, |
1144 | struct GNUNET_CONTAINER_SList *src); | ||
1107 | 1145 | ||
1108 | 1146 | ||
1109 | /** | 1147 | /** |
@@ -1126,8 +1164,9 @@ void GNUNET_CONTAINER_slist_destroy (struct GNUNET_CONTAINER_SList *l); | |||
1126 | * @param l list | 1164 | * @param l list |
1127 | * @return iterator pointing to the beginning, free using "GNUNET_free" | 1165 | * @return iterator pointing to the beginning, free using "GNUNET_free" |
1128 | */ | 1166 | */ |
1129 | struct GNUNET_CONTAINER_SList_Iterator * | 1167 | struct GNUNET_CONTAINER_SList_Iterator *GNUNET_CONTAINER_slist_begin (struct |
1130 | GNUNET_CONTAINER_slist_begin(struct GNUNET_CONTAINER_SList *l); | 1168 | GNUNET_CONTAINER_SList |
1169 | *l); | ||
1131 | 1170 | ||
1132 | 1171 | ||
1133 | /** | 1172 | /** |
@@ -1144,7 +1183,8 @@ void GNUNET_CONTAINER_slist_clear (struct GNUNET_CONTAINER_SList *l); | |||
1144 | * @param buf payload buffer to find | 1183 | * @param buf payload buffer to find |
1145 | * @param len length of the payload (number of bytes in buf) | 1184 | * @param len length of the payload (number of bytes in buf) |
1146 | */ | 1185 | */ |
1147 | int GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l, const void *buf, size_t len); | 1186 | int GNUNET_CONTAINER_slist_contains (const struct GNUNET_CONTAINER_SList *l, |
1187 | const void *buf, size_t len); | ||
1148 | 1188 | ||
1149 | 1189 | ||
1150 | /** | 1190 | /** |
@@ -1169,10 +1209,10 @@ void GNUNET_CONTAINER_slist_erase (struct GNUNET_CONTAINER_SList_Iterator *i); | |||
1169 | * @param buf payload buffer | 1209 | * @param buf payload buffer |
1170 | * @param len length of the payload | 1210 | * @param len length of the payload |
1171 | */ | 1211 | */ |
1172 | void GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator *before, | 1212 | void GNUNET_CONTAINER_slist_insert (struct GNUNET_CONTAINER_SList_Iterator |
1173 | enum GNUNET_CONTAINER_SListDisposition disp, | 1213 | *before, |
1174 | const void *buf, | 1214 | enum GNUNET_CONTAINER_SListDisposition disp, |
1175 | size_t len); | 1215 | const void *buf, size_t len); |
1176 | 1216 | ||
1177 | 1217 | ||
1178 | /** | 1218 | /** |
@@ -1199,16 +1239,16 @@ int GNUNET_CONTAINER_slist_end (struct GNUNET_CONTAINER_SList_Iterator *i); | |||
1199 | * @param len set to the payload length | 1239 | * @param len set to the payload length |
1200 | * @return payload | 1240 | * @return payload |
1201 | */ | 1241 | */ |
1202 | void * | 1242 | void *GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator |
1203 | GNUNET_CONTAINER_slist_get (const struct GNUNET_CONTAINER_SList_Iterator *i, | 1243 | *i, size_t * len); |
1204 | size_t *len); | ||
1205 | 1244 | ||
1206 | 1245 | ||
1207 | /** | 1246 | /** |
1208 | * Release an iterator | 1247 | * Release an iterator |
1209 | * @param i iterator | 1248 | * @param i iterator |
1210 | */ | 1249 | */ |
1211 | void GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator *i); | 1250 | void GNUNET_CONTAINER_slist_iter_destroy (struct GNUNET_CONTAINER_SList_Iterator |
1251 | *i); | ||
1212 | 1252 | ||
1213 | 1253 | ||
1214 | #if 0 /* keep Emacsens' auto-indent happy */ | 1254 | #if 0 /* keep Emacsens' auto-indent happy */ |