GNUnet  0.10.x
container_multishortmap.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2008, 2012 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 
29 #define LOG(kind, ...) \
30  GNUNET_log_from(kind, "util-container-multishortmap", __VA_ARGS__)
31 
38 #define NEXT_CACHE_SIZE 16
39 
40 
44 struct BigMapEntry {
48  void *value;
49 
53  struct BigMapEntry *next;
54 
59 };
60 
61 
65 struct SmallMapEntry {
69  void *value;
70 
74  struct SmallMapEntry *next;
75 
79  const struct GNUNET_ShortHashCode *key;
80 };
81 
82 
86 union MapEntry {
90  struct SmallMapEntry *sme;
91 
95  struct BigMapEntry *bme;
96 };
97 
98 
106  union MapEntry *map;
107 
111  unsigned int size;
112 
116  unsigned int map_length;
117 
123 
128  unsigned int modification_counter;
129 
135  union MapEntry next_cache[NEXT_CACHE_SIZE];
136 
141  unsigned int next_cache_off;
142 };
143 
144 
153  union MapEntry me;
154 
158  unsigned int idx;
159 
164  unsigned int modification_counter;
165 
170 };
171 
172 
189 GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
190 {
192 
193  GNUNET_assert(len > 0);
195  map->map = GNUNET_malloc_large(len * sizeof(union MapEntry));
196  if (NULL == map->map)
197  {
198  GNUNET_free(map);
199  return NULL;
200  }
201  map->map_length = len;
202  map->use_small_entries = do_not_copy_keys;
203  return map;
204 }
205 
206 
213 void
216 {
217  GNUNET_assert(0 == map->next_cache_off);
218  for (unsigned int i = 0; i < map->map_length; i++)
219  {
220  union MapEntry me;
221 
222  me = map->map[i];
223  if (map->use_small_entries)
224  {
225  struct SmallMapEntry *sme;
226  struct SmallMapEntry *nxt;
227 
228  nxt = me.sme;
229  while (NULL != (sme = nxt))
230  {
231  nxt = sme->next;
232  GNUNET_free(sme);
233  }
234  me.sme = NULL;
235  }
236  else
237  {
238  struct BigMapEntry *bme;
239  struct BigMapEntry *nxt;
240 
241  nxt = me.bme;
242  while (NULL != (bme = nxt))
243  {
244  nxt = bme->next;
245  GNUNET_free(bme);
246  }
247  me.bme = NULL;
248  }
249  }
250  GNUNET_free(map->map);
251  GNUNET_free(map);
252 }
253 
254 
262 static unsigned int
264  const struct GNUNET_ShortHashCode *key)
265 {
266  unsigned int kx;
267 
268  GNUNET_assert(NULL != map);
269  GNUNET_memcpy(&kx, key, sizeof(kx));
270  return kx % map->map_length;
271 }
272 
273 
280 unsigned int
282  const struct GNUNET_CONTAINER_MultiShortmap *map)
283 {
284  return map->size;
285 }
286 
287 
298 void *
300  const struct GNUNET_CONTAINER_MultiShortmap *map,
301  const struct GNUNET_ShortHashCode *key)
302 {
303  union MapEntry me;
304 
305  me = map->map[idx_of(map, key)];
306  if (map->use_small_entries)
307  {
308  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
309  if (0 == GNUNET_memcmp(key, sme->key))
310  return sme->value;
311  }
312  else
313  {
314  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
315  if (0 == GNUNET_memcmp(key, &bme->key))
316  return bme->value;
317  }
318  return NULL;
319 }
320 
321 
331 int
335  void *it_cls)
336 {
337  int count;
338  union MapEntry me;
339  union MapEntry *ce;
340  struct GNUNET_ShortHashCode kc;
341 
342  count = 0;
343  GNUNET_assert(NULL != map);
344  ce = &map->next_cache[map->next_cache_off];
346  for (unsigned int i = 0; i < map->map_length; i++)
347  {
348  me = map->map[i];
349  if (map->use_small_entries)
350  {
351  struct SmallMapEntry *sme;
352 
353  ce->sme = me.sme;
354  while (NULL != (sme = ce->sme))
355  {
356  ce->sme = sme->next;
357  if ((NULL != it) && (GNUNET_OK != it(it_cls, sme->key, sme->value)))
358  {
360  return GNUNET_SYSERR;
361  }
362  count++;
363  }
364  }
365  else
366  {
367  struct BigMapEntry *bme;
368 
369  ce->bme = me.bme;
370  while (NULL != (bme = ce->bme))
371  {
372  ce->bme = bme->next;
373  if (NULL != it)
374  {
375  kc = bme->key;
376  if (GNUNET_OK != it(it_cls, &kc, bme->value))
377  {
379  return GNUNET_SYSERR;
380  }
381  }
382  count++;
383  }
384  }
385  }
387  return count;
388 }
389 
390 
398 static void
400  const struct BigMapEntry *bme)
401 {
402  for (unsigned int i = 0; i < map->next_cache_off; i++)
403  if (map->next_cache[i].bme == bme)
404  map->next_cache[i].bme = bme->next;
405 }
406 
407 
415 static void
417  const struct SmallMapEntry *sme)
418 {
419  for (unsigned int i = 0; i < map->next_cache_off; i++)
420  if (map->next_cache[i].sme == sme)
421  map->next_cache[i].sme = sme->next;
422 }
423 
424 
436 int
439  const struct GNUNET_ShortHashCode *key,
440  const void *value)
441 {
442  union MapEntry me;
443  unsigned int i;
444 
445  map->modification_counter++;
446  i = idx_of(map, key);
447  me = map->map[i];
448  if (map->use_small_entries)
449  {
450  struct SmallMapEntry *p = NULL;
451 
452  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
453  {
454  if ((0 == GNUNET_memcmp(key, sme->key)) && (value == sme->value))
455  {
456  if (NULL == p)
457  map->map[i].sme = sme->next;
458  else
459  p->next = sme->next;
460  update_next_cache_sme(map, sme);
461  GNUNET_free(sme);
462  map->size--;
463  return GNUNET_YES;
464  }
465  p = sme;
466  }
467  }
468  else
469  {
470  struct BigMapEntry *p = NULL;
471 
472  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
473  {
474  if ((0 == GNUNET_memcmp(key, &bme->key)) && (value == bme->value))
475  {
476  if (NULL == p)
477  map->map[i].bme = bme->next;
478  else
479  p->next = bme->next;
480  update_next_cache_bme(map, bme);
481  GNUNET_free(bme);
482  map->size--;
483  return GNUNET_YES;
484  }
485  p = bme;
486  }
487  }
488  return GNUNET_NO;
489 }
490 
491 
500 int
503  const struct GNUNET_ShortHashCode *key)
504 {
505  union MapEntry me;
506  unsigned int i;
507  int ret;
508 
509  map->modification_counter++;
510 
511  ret = 0;
512  i = idx_of(map, key);
513  me = map->map[i];
514  if (map->use_small_entries)
515  {
516  struct SmallMapEntry *sme;
517  struct SmallMapEntry *p;
518 
519  p = NULL;
520  sme = me.sme;
521  while (NULL != sme)
522  {
523  if (0 == GNUNET_memcmp(key, sme->key))
524  {
525  if (NULL == p)
526  map->map[i].sme = sme->next;
527  else
528  p->next = sme->next;
529  update_next_cache_sme(map, sme);
530  GNUNET_free(sme);
531  map->size--;
532  if (NULL == p)
533  sme = map->map[i].sme;
534  else
535  sme = p->next;
536  ret++;
537  }
538  else
539  {
540  p = sme;
541  sme = sme->next;
542  }
543  }
544  }
545  else
546  {
547  struct BigMapEntry *bme;
548  struct BigMapEntry *p;
549 
550  p = NULL;
551  bme = me.bme;
552  while (NULL != bme)
553  {
554  if (0 == GNUNET_memcmp(key, &bme->key))
555  {
556  if (NULL == p)
557  map->map[i].bme = bme->next;
558  else
559  p->next = bme->next;
560  update_next_cache_bme(map, bme);
561  GNUNET_free(bme);
562  map->size--;
563  if (NULL == p)
564  bme = map->map[i].bme;
565  else
566  bme = p->next;
567  ret++;
568  }
569  else
570  {
571  p = bme;
572  bme = bme->next;
573  }
574  }
575  }
576  return ret;
577 }
578 
579 
589 int
591  const struct GNUNET_CONTAINER_MultiShortmap *map,
592  const struct GNUNET_ShortHashCode *key)
593 {
594  union MapEntry me;
595 
596  me = map->map[idx_of(map, key)];
597  if (map->use_small_entries)
598  {
599  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
600  if (0 == GNUNET_memcmp(key, sme->key))
601  return GNUNET_YES;
602  }
603  else
604  {
605  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
606  if (0 == GNUNET_memcmp(key, &bme->key))
607  return GNUNET_YES;
608  }
609  return GNUNET_NO;
610 }
611 
612 
623 int
625  const struct GNUNET_CONTAINER_MultiShortmap *map,
626  const struct GNUNET_ShortHashCode *key,
627  const void *value)
628 {
629  union MapEntry me;
630 
631  me = map->map[idx_of(map, key)];
632  if (map->use_small_entries)
633  {
634  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
635  if ((0 == GNUNET_memcmp(key, sme->key)) && (sme->value == value))
636  return GNUNET_YES;
637  }
638  else
639  {
640  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
641  if ((0 == GNUNET_memcmp(key, &bme->key)) && (bme->value == value))
642  return GNUNET_YES;
643  }
644  return GNUNET_NO;
645 }
646 
647 
653 static void
655 {
656  union MapEntry *old_map;
657  union MapEntry *new_map;
658  unsigned int old_len;
659  unsigned int new_len;
660  unsigned int idx;
661 
662  old_map = map->map;
663  old_len = map->map_length;
664  new_len = old_len * 2;
665  if (0 == new_len) /* 2^31 * 2 == 0 */
666  new_len = old_len; /* never use 0 */
667  if (new_len == old_len)
668  return; /* nothing changed */
669  new_map = GNUNET_malloc_large(new_len * sizeof(union MapEntry));
670  if (NULL == new_map)
671  return; /* grow not possible */
672  map->modification_counter++;
673  map->map_length = new_len;
674  map->map = new_map;
675  for (unsigned int i = 0; i < old_len; i++)
676  {
677  if (map->use_small_entries)
678  {
679  struct SmallMapEntry *sme;
680 
681  while (NULL != (sme = old_map[i].sme))
682  {
683  old_map[i].sme = sme->next;
684  idx = idx_of(map, sme->key);
685  sme->next = new_map[idx].sme;
686  new_map[idx].sme = sme;
687  }
688  }
689  else
690  {
691  struct BigMapEntry *bme;
692 
693  while (NULL != (bme = old_map[i].bme))
694  {
695  old_map[i].bme = bme->next;
696  idx = idx_of(map, &bme->key);
697  bme->next = new_map[idx].bme;
698  new_map[idx].bme = bme;
699  }
700  }
701  }
702  GNUNET_free(old_map);
703 }
704 
705 
718 int
721  const struct GNUNET_ShortHashCode *key,
722  void *value,
724 {
725  union MapEntry me;
726  unsigned int i;
727 
728  i = idx_of(map, key);
731  {
732  me = map->map[i];
733  if (map->use_small_entries)
734  {
735  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
736  if (0 == GNUNET_memcmp(key, sme->key))
737  {
739  return GNUNET_SYSERR;
740  sme->value = value;
741  return GNUNET_NO;
742  }
743  }
744  else
745  {
746  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
747  if (0 == GNUNET_memcmp(key, &bme->key))
748  {
750  return GNUNET_SYSERR;
751  bme->value = value;
752  return GNUNET_NO;
753  }
754  }
755  }
756  if (map->size / 3 >= map->map_length / 4)
757  {
758  grow(map);
759  i = idx_of(map, key);
760  }
761  if (map->use_small_entries)
762  {
763  struct SmallMapEntry *sme;
764 
765  sme = GNUNET_new(struct SmallMapEntry);
766  sme->key = key;
767  sme->value = value;
768  sme->next = map->map[i].sme;
769  map->map[i].sme = sme;
770  }
771  else
772  {
773  struct BigMapEntry *bme;
774 
775  bme = GNUNET_new(struct BigMapEntry);
776  bme->key = *key;
777  bme->value = value;
778  bme->next = map->map[i].bme;
779  map->map[i].bme = bme;
780  }
781  map->size++;
782  return GNUNET_OK;
783 }
784 
785 
796 int
799  const struct GNUNET_ShortHashCode *key,
801  void *it_cls)
802 {
803  int count;
804  union MapEntry me;
805  union MapEntry *ce;
806 
807  ce = &map->next_cache[map->next_cache_off];
809  count = 0;
810  me = map->map[idx_of(map, key)];
811  if (map->use_small_entries)
812  {
813  struct SmallMapEntry *sme;
814 
815  ce->sme = me.sme;
816  while (NULL != (sme = ce->sme))
817  {
818  ce->sme = sme->next;
819  if (0 != GNUNET_memcmp(key, sme->key))
820  continue;
821  if ((NULL != it) && (GNUNET_OK != it(it_cls, key, sme->value)))
822  {
824  return GNUNET_SYSERR;
825  }
826  count++;
827  }
828  }
829  else
830  {
831  struct BigMapEntry *bme;
832 
833  ce->bme = me.bme;
834  while (NULL != (bme = ce->bme))
835  {
836  ce->bme = bme->next;
837  if (0 != GNUNET_memcmp(key, &bme->key))
838  continue;
839  if ((NULL != it) && (GNUNET_OK != it(it_cls, key, bme->value)))
840  {
842  return GNUNET_SYSERR;
843  }
844  count++;
845  }
846  }
848  return count;
849 }
850 
851 
863 unsigned int
865  const struct GNUNET_CONTAINER_MultiShortmap *map,
867  void *it_cls)
868 {
869  unsigned int off;
870  union MapEntry me;
871 
872  if (0 == map->size)
873  return 0;
874  if (NULL == it)
875  return 1;
877  for (unsigned int idx = 0; idx < map->map_length; idx++)
878  {
879  me = map->map[idx];
880  if (map->use_small_entries)
881  {
882  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
883  {
884  if (0 == off)
885  {
886  if (GNUNET_OK != it(it_cls, sme->key, sme->value))
887  return GNUNET_SYSERR;
888  return 1;
889  }
890  off--;
891  }
892  }
893  else
894  {
895  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
896  {
897  if (0 == off)
898  {
899  if (GNUNET_OK != it(it_cls, &bme->key, bme->value))
900  return GNUNET_SYSERR;
901  return 1;
902  }
903  off--;
904  }
905  }
906  }
907  GNUNET_break(0);
908  return GNUNET_SYSERR;
909 }
910 
911 
926  const struct GNUNET_CONTAINER_MultiShortmap *map)
927 {
929 
931  iter->map = map;
933  iter->me = map->map[0];
934  return iter;
935 }
936 
937 
952 int
955  struct GNUNET_ShortHashCode *key,
956  const void **value)
957 {
958  /* make sure the map has not been modified */
960 
961  /* look for the next entry, skipping empty buckets */
962  while (1)
963  {
964  if (iter->idx >= iter->map->map_length)
965  return GNUNET_NO;
966  if (GNUNET_YES == iter->map->use_small_entries)
967  {
968  if (NULL != iter->me.sme)
969  {
970  if (NULL != key)
971  *key = *iter->me.sme->key;
972  if (NULL != value)
973  *value = iter->me.sme->value;
974  iter->me.sme = iter->me.sme->next;
975  return GNUNET_YES;
976  }
977  }
978  else
979  {
980  if (NULL != iter->me.bme)
981  {
982  if (NULL != key)
983  *key = iter->me.bme->key;
984  if (NULL != value)
985  *value = iter->me.bme->value;
986  iter->me.bme = iter->me.bme->next;
987  return GNUNET_YES;
988  }
989  }
990  iter->idx += 1;
991  if (iter->idx < iter->map->map_length)
992  iter->me = iter->map->map[iter->idx];
993  }
994 }
995 
996 
1002 void
1005 {
1006  GNUNET_free(iter);
1007 }
1008 
1009 
1010 /* end of container_multishortmap.c */
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
GNUNET_CONTAINER_MultiHashMapOption
Options for storing values in the HashMap.
struct SmallMapEntry * next
If there is a hash collision, we create a linked list.
unsigned int map_length
Length of the "map" array.
unsigned int modification_counter
Modification counter as observed on the map when the iterator was created.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
void * value
Value of the entry.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
unsigned int GNUNET_CONTAINER_multishortmap_get_random(const struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Call it on a random value from the map, or not at all if the map is empty.
union MapEntry me
Position in the bucket &#39;idx&#39;.
int GNUNET_CONTAINER_multishortmap_get_multiple(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
unsigned int idx
Current bucket index.
const struct GNUNET_HashCode * key
Key for the entry.
void GNUNET_CONTAINER_multishortmap_iterator_destroy(struct GNUNET_CONTAINER_MultiShortmapIterator *iter)
Destroy a multishortmap iterator.
#define GNUNET_NO
Definition: gnunet_common.h:78
void * value
Value of the entry.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void update_next_cache_bme(struct GNUNET_CONTAINER_MultiShortmap *map, const struct BigMapEntry *bme)
We are about to free() the bme, make sure it is not in the list of next values for any iterator in th...
const struct GNUNET_CONTAINER_MultiShortmap * map
Map that we are iterating over.
struct SmallMapEntry * sme
Variant used if map entries only contain a pointer to the key.
int(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct BigMapEntry * next
If there is a hash collision, we create a linked list.
A 256-bit hashcode.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
, &#39; bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
static unsigned int idx_of(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Compute the index of the bucket for the given key.
Entry in the map.
unsigned int size
Number of entries in the map.
Randomness for IVs etc.
int GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
static void grow(struct GNUNET_CONTAINER_MultiShortmap *map)
Grow the given map to a more appropriate size.
struct GNUNET_CONTAINER_MultiShortmapIterator * GNUNET_CONTAINER_multishortmap_iterator_create(const struct GNUNET_CONTAINER_MultiShortmap *map)
Create an iterator for a multishortmap.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
int GNUNET_CONTAINER_multishortmap_remove_all(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Remove all entries for the given key from the map.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
int use_small_entries
GNUNET_NO if the map entries are of type &#39;struct BigMapEntry&#39;, GNUNET_YES if the map entries are of t...
unsigned int next_cache_off
Offset of next_cache entries in use, must be smaller than NEXT_CACHE_SIZE.
Internal representation of the hash map.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
const struct GNUNET_ShortHashCode * key
Key for the entry.
#define NEXT_CACHE_SIZE
Maximum recursion depth for callbacks of GNUNET_CONTAINER_multihashmap_get_multiple() themselve s aga...
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
Allow multiple values with the same key.
unsigned int modification_counter
Counts the destructive modifications (grow, remove) to the map, so that iterators can check if they a...
An entry in the hash map with just a pointer to the key.
union MapEntry next_cache[16]
Map entries indicating iteration positions currently in use by GNUNET_CONTAINER_multihashmap_get_mult...
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
An entry in the hash map with the full key.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct BigMapEntry * bme
Variant used if map entries contain the full key.
static void update_next_cache_sme(struct GNUNET_CONTAINER_MultiShortmap *map, const struct SmallMapEntry *sme)
We are about to free() the sme, make sure it is not in the list of next values for any iterator in th...
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
int GNUNET_CONTAINER_multishortmap_contains_value(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Check if the map contains the given value under the given key.
int GNUNET_CONTAINER_multishortmap_iterator_next(struct GNUNET_CONTAINER_MultiShortmapIterator *iter, struct GNUNET_ShortHashCode *key, const void **value)
Retrieve the next element from the hash map at the iterator&#39;s position.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_HashCode key
Key for the entry.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
union MapEntry * map
All of our buckets.