GNUnet  0.20.0
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  */
27 #include "gnunet_common.h"
28 #include "platform.h"
29 #include "gnunet_util_lib.h"
30 
31 #define LOG(kind, ...) \
32  GNUNET_log_from (kind, "util-container-multishortmap", __VA_ARGS__)
33 
40 #define NEXT_CACHE_SIZE 16
41 
42 
46 struct BigMapEntry
47 {
51  void *value;
52 
56  struct BigMapEntry *next;
57 
62 };
63 
64 
68 struct SmallMapEntry
69 {
73  void *value;
74 
78  struct SmallMapEntry *next;
79 
83  const struct GNUNET_ShortHashCode *key;
84 };
85 
86 
90 union MapEntry
91 {
95  struct SmallMapEntry *sme;
96 
100  struct BigMapEntry *bme;
101 };
102 
103 
108 {
112  union MapEntry *map;
113 
117  unsigned int size;
118 
122  unsigned int map_length;
123 
129 
134  unsigned int modification_counter;
135 
142 
147  unsigned int next_cache_off;
148 };
149 
150 
156 {
160  union MapEntry me;
161 
165  unsigned int idx;
166 
171  unsigned int modification_counter;
172 
177 };
178 
179 
196 GNUNET_CONTAINER_multishortmap_create (unsigned int len, int do_not_copy_keys)
197 {
199 
200  GNUNET_assert (len > 0);
202  map->map = GNUNET_malloc_large (len * sizeof(union MapEntry));
203  if (NULL == map->map)
204  {
205  GNUNET_free (map);
206  return NULL;
207  }
208  map->map_length = len;
209  map->use_small_entries = do_not_copy_keys;
210  return map;
211 }
212 
213 
214 void
217 {
219  for (unsigned int i = 0; i < map->map_length; i++)
220  {
221  union MapEntry me;
222 
223  me = map->map[i];
224  if (map->use_small_entries)
225  {
226  struct SmallMapEntry *sme;
227  struct SmallMapEntry *nxt;
228 
229  nxt = me.sme;
230  while (NULL != (sme = nxt))
231  {
232  nxt = sme->next;
233  GNUNET_free (sme);
234  }
235  me.sme = NULL;
236  }
237  else
238  {
239  struct BigMapEntry *bme;
240  struct BigMapEntry *nxt;
241 
242  nxt = me.bme;
243  while (NULL != (bme = nxt))
244  {
245  nxt = bme->next;
246  GNUNET_free (bme);
247  }
248  me.bme = NULL;
249  }
250  }
251  GNUNET_free (map->map);
252  GNUNET_free (map);
253 }
254 
255 
263 static unsigned int
265  const struct GNUNET_ShortHashCode *key)
266 {
267  unsigned int kx;
268 
269  GNUNET_assert (NULL != map);
270  GNUNET_memcpy (&kx, key, sizeof(kx));
271  return kx % map->map_length;
272 }
273 
274 
275 unsigned int
277  const struct GNUNET_CONTAINER_MultiShortmap *map)
278 {
279  return map->size;
280 }
281 
282 
283 void *
285  const struct GNUNET_CONTAINER_MultiShortmap *map,
286  const struct GNUNET_ShortHashCode *key)
287 {
288  union MapEntry me;
289 
290  me = map->map[idx_of (map, key)];
291  if (map->use_small_entries)
292  {
293  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
294  if (0 == GNUNET_memcmp (key, sme->key))
295  return sme->value;
296  }
297  else
298  {
299  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
300  if (0 == GNUNET_memcmp (key, &bme->key))
301  return bme->value;
302  }
303  return NULL;
304 }
305 
306 
307 int
311  void *it_cls)
312 {
313  int count;
314  union MapEntry me;
315  union MapEntry *ce;
316  struct GNUNET_ShortHashCode kc;
317 
318  count = 0;
319  GNUNET_assert (NULL != map);
320  ce = &map->next_cache[map->next_cache_off];
322  for (unsigned int i = 0; i < map->map_length; i++)
323  {
324  me = map->map[i];
325  if (map->use_small_entries)
326  {
327  struct SmallMapEntry *sme;
328 
329  ce->sme = me.sme;
330  while (NULL != (sme = ce->sme))
331  {
332  ce->sme = sme->next;
333  if ((NULL != it) && (GNUNET_OK != it (it_cls, sme->key, sme->value)))
334  {
336  return GNUNET_SYSERR;
337  }
338  count++;
339  }
340  }
341  else
342  {
343  struct BigMapEntry *bme;
344 
345  ce->bme = me.bme;
346  while (NULL != (bme = ce->bme))
347  {
348  ce->bme = bme->next;
349  if (NULL != it)
350  {
351  kc = bme->key;
352  if (GNUNET_OK != it (it_cls, &kc, bme->value))
353  {
355  return GNUNET_SYSERR;
356  }
357  }
358  count++;
359  }
360  }
361  }
363  return count;
364 }
365 
366 
374 static void
376  const struct BigMapEntry *bme)
377 {
378  for (unsigned int i = 0; i < map->next_cache_off; i++)
379  if (map->next_cache[i].bme == bme)
380  map->next_cache[i].bme = bme->next;
381 }
382 
383 
391 static void
393  const struct SmallMapEntry *sme)
394 {
395  for (unsigned int i = 0; i < map->next_cache_off; i++)
396  if (map->next_cache[i].sme == sme)
397  map->next_cache[i].sme = sme->next;
398 }
399 
400 
401 int
404  const struct GNUNET_ShortHashCode *key,
405  const void *value)
406 {
407  union MapEntry me;
408  unsigned int i;
409 
411  i = idx_of (map, key);
412  me = map->map[i];
413  if (map->use_small_entries)
414  {
415  struct SmallMapEntry *p = NULL;
416 
417  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
418  {
419  if ((0 == GNUNET_memcmp (key, sme->key)) && (value == sme->value))
420  {
421  if (NULL == p)
422  map->map[i].sme = sme->next;
423  else
424  p->next = sme->next;
425  update_next_cache_sme (map, sme);
426  GNUNET_free (sme);
427  map->size--;
428  return GNUNET_YES;
429  }
430  p = sme;
431  }
432  }
433  else
434  {
435  struct BigMapEntry *p = NULL;
436 
437  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
438  {
439  if ((0 == GNUNET_memcmp (key, &bme->key)) && (value == bme->value))
440  {
441  if (NULL == p)
442  map->map[i].bme = bme->next;
443  else
444  p->next = bme->next;
445  update_next_cache_bme (map, bme);
446  GNUNET_free (bme);
447  map->size--;
448  return GNUNET_YES;
449  }
450  p = bme;
451  }
452  }
453  return GNUNET_NO;
454 }
455 
456 
457 int
460  const struct GNUNET_ShortHashCode *key)
461 {
462  union MapEntry me;
463  unsigned int i;
464  int ret;
465 
467 
468  ret = 0;
469  i = idx_of (map, key);
470  me = map->map[i];
471  if (map->use_small_entries)
472  {
473  struct SmallMapEntry *sme;
474  struct SmallMapEntry *p;
475 
476  p = NULL;
477  sme = me.sme;
478  while (NULL != sme)
479  {
480  if (0 == GNUNET_memcmp (key, sme->key))
481  {
482  if (NULL == p)
483  map->map[i].sme = sme->next;
484  else
485  p->next = sme->next;
486  update_next_cache_sme (map, sme);
487  GNUNET_free (sme);
488  map->size--;
489  if (NULL == p)
490  sme = map->map[i].sme;
491  else
492  sme = p->next;
493  ret++;
494  }
495  else
496  {
497  p = sme;
498  sme = sme->next;
499  }
500  }
501  }
502  else
503  {
504  struct BigMapEntry *bme;
505  struct BigMapEntry *p;
506 
507  p = NULL;
508  bme = me.bme;
509  while (NULL != bme)
510  {
511  if (0 == GNUNET_memcmp (key, &bme->key))
512  {
513  if (NULL == p)
514  map->map[i].bme = bme->next;
515  else
516  p->next = bme->next;
517  update_next_cache_bme (map, bme);
518  GNUNET_free (bme);
519  map->size--;
520  if (NULL == p)
521  bme = map->map[i].bme;
522  else
523  bme = p->next;
524  ret++;
525  }
526  else
527  {
528  p = bme;
529  bme = bme->next;
530  }
531  }
532  }
533  return ret;
534 }
535 
536 
537 int
539  const struct GNUNET_CONTAINER_MultiShortmap *map,
540  const struct GNUNET_ShortHashCode *key)
541 {
542  union MapEntry me;
543 
544  me = map->map[idx_of (map, key)];
545  if (map->use_small_entries)
546  {
547  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
548  if (0 == GNUNET_memcmp (key, sme->key))
549  return GNUNET_YES;
550  }
551  else
552  {
553  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
554  if (0 == GNUNET_memcmp (key, &bme->key))
555  return GNUNET_YES;
556  }
557  return GNUNET_NO;
558 }
559 
560 
561 int
563  const struct GNUNET_CONTAINER_MultiShortmap *map,
564  const struct GNUNET_ShortHashCode *key,
565  const void *value)
566 {
567  union MapEntry me;
568 
569  me = map->map[idx_of (map, key)];
570  if (map->use_small_entries)
571  {
572  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
573  if ((0 == GNUNET_memcmp (key, sme->key)) && (sme->value == value))
574  return GNUNET_YES;
575  }
576  else
577  {
578  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
579  if ((0 == GNUNET_memcmp (key, &bme->key)) && (bme->value == value))
580  return GNUNET_YES;
581  }
582  return GNUNET_NO;
583 }
584 
585 
591 static void
593 {
594  union MapEntry *old_map;
595  union MapEntry *new_map;
596  unsigned int old_len;
597  unsigned int new_len;
598  unsigned int idx;
599 
600  old_map = map->map;
601  old_len = map->map_length;
602  new_len = old_len * 2;
603  if (0 == new_len) /* 2^31 * 2 == 0 */
604  new_len = old_len; /* never use 0 */
605  if (new_len == old_len)
606  return; /* nothing changed */
607  new_map = GNUNET_malloc_large (new_len * sizeof(union MapEntry));
608  if (NULL == new_map)
609  return; /* grow not possible */
611  map->map_length = new_len;
612  map->map = new_map;
613  for (unsigned int i = 0; i < old_len; i++)
614  {
615  if (map->use_small_entries)
616  {
617  struct SmallMapEntry *sme;
618 
619  while (NULL != (sme = old_map[i].sme))
620  {
621  old_map[i].sme = sme->next;
622  idx = idx_of (map, sme->key);
623  sme->next = new_map[idx].sme;
624  new_map[idx].sme = sme;
625  }
626  }
627  else
628  {
629  struct BigMapEntry *bme;
630 
631  while (NULL != (bme = old_map[i].bme))
632  {
633  old_map[i].bme = bme->next;
634  idx = idx_of (map, &bme->key);
635  bme->next = new_map[idx].bme;
636  new_map[idx].bme = bme;
637  }
638  }
639  }
640  GNUNET_free (old_map);
641 }
642 
643 
647  const struct GNUNET_ShortHashCode *key,
648  void *value,
650 {
651  union MapEntry me;
652  unsigned int i;
653 
654  i = idx_of (map, key);
657  {
658  me = map->map[i];
659  if (map->use_small_entries)
660  {
661  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
662  if (0 == GNUNET_memcmp (key, sme->key))
663  {
665  return GNUNET_SYSERR;
666  sme->value = value;
667  return GNUNET_NO;
668  }
669  }
670  else
671  {
672  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
673  if (0 == GNUNET_memcmp (key, &bme->key))
674  {
676  return GNUNET_SYSERR;
677  bme->value = value;
678  return GNUNET_NO;
679  }
680  }
681  }
682  if (map->size / 3 >= map->map_length / 4)
683  {
684  grow (map);
685  i = idx_of (map, key);
686  }
687  if (map->use_small_entries)
688  {
689  struct SmallMapEntry *sme;
690 
691  sme = GNUNET_new (struct SmallMapEntry);
692  sme->key = key;
693  sme->value = value;
694  sme->next = map->map[i].sme;
695  map->map[i].sme = sme;
696  }
697  else
698  {
699  struct BigMapEntry *bme;
700 
701  bme = GNUNET_new (struct BigMapEntry);
702  bme->key = *key;
703  bme->value = value;
704  bme->next = map->map[i].bme;
705  map->map[i].bme = bme;
706  }
707  map->size++;
708  return GNUNET_OK;
709 }
710 
711 
722 int
725  const struct GNUNET_ShortHashCode *key,
727  void *it_cls)
728 {
729  int count;
730  union MapEntry me;
731  union MapEntry *ce;
732 
733  ce = &map->next_cache[map->next_cache_off];
735  count = 0;
736  me = map->map[idx_of (map, key)];
737  if (map->use_small_entries)
738  {
739  struct SmallMapEntry *sme;
740 
741  ce->sme = me.sme;
742  while (NULL != (sme = ce->sme))
743  {
744  ce->sme = sme->next;
745  if (0 != GNUNET_memcmp (key, sme->key))
746  continue;
747  if ((NULL != it) && (GNUNET_OK != it (it_cls, key, sme->value)))
748  {
750  return GNUNET_SYSERR;
751  }
752  count++;
753  }
754  }
755  else
756  {
757  struct BigMapEntry *bme;
758 
759  ce->bme = me.bme;
760  while (NULL != (bme = ce->bme))
761  {
762  ce->bme = bme->next;
763  if (0 != GNUNET_memcmp (key, &bme->key))
764  continue;
765  if ((NULL != it) && (GNUNET_OK != it (it_cls, key, bme->value)))
766  {
768  return GNUNET_SYSERR;
769  }
770  count++;
771  }
772  }
774  return count;
775 }
776 
777 
789 unsigned int
791  const struct GNUNET_CONTAINER_MultiShortmap *map,
793  void *it_cls)
794 {
795  unsigned int off;
796  union MapEntry me;
797 
798  if (0 == map->size)
799  return 0;
800  if (NULL == it)
801  return 1;
803  for (unsigned int idx = 0; idx < map->map_length; idx++)
804  {
805  me = map->map[idx];
806  if (map->use_small_entries)
807  {
808  for (struct SmallMapEntry *sme = me.sme; NULL != sme; sme = sme->next)
809  {
810  if (0 == off)
811  {
812  if (GNUNET_OK != it (it_cls, sme->key, sme->value))
813  return GNUNET_SYSERR;
814  return 1;
815  }
816  off--;
817  }
818  }
819  else
820  {
821  for (struct BigMapEntry *bme = me.bme; NULL != bme; bme = bme->next)
822  {
823  if (0 == off)
824  {
825  if (GNUNET_OK != it (it_cls, &bme->key, bme->value))
826  return GNUNET_SYSERR;
827  return 1;
828  }
829  off--;
830  }
831  }
832  }
833  GNUNET_break (0);
834  return GNUNET_SYSERR;
835 }
836 
837 
840  const struct GNUNET_CONTAINER_MultiShortmap *map)
841 {
843 
845  iter->map = map;
847  iter->me = map->map[0];
848  return iter;
849 }
850 
851 
855  struct GNUNET_ShortHashCode *key,
856  const void **value)
857 {
858  /* make sure the map has not been modified */
860 
861  /* look for the next entry, skipping empty buckets */
862  while (1)
863  {
864  if (iter->idx >= iter->map->map_length)
865  return GNUNET_NO;
866  if (GNUNET_YES == iter->map->use_small_entries)
867  {
868  if (NULL != iter->me.sme)
869  {
870  if (NULL != key)
871  *key = *iter->me.sme->key;
872  if (NULL != value)
873  *value = iter->me.sme->value;
874  iter->me.sme = iter->me.sme->next;
875  return GNUNET_YES;
876  }
877  }
878  else
879  {
880  if (NULL != iter->me.bme)
881  {
882  if (NULL != key)
883  *key = iter->me.bme->key;
884  if (NULL != value)
885  *value = iter->me.bme->value;
886  iter->me.bme = iter->me.bme->next;
887  return GNUNET_YES;
888  }
889  }
890  iter->idx += 1;
891  if (iter->idx < iter->map->map_length)
892  iter->me = iter->map->map[iter->idx];
893  }
894 }
895 
896 
897 void
900 {
901  GNUNET_free (iter);
902 }
903 
904 
905 /* end of container_multishortmap.c */
#define NEXT_CACHE_SIZE
Maximum recursion depth for callbacks of GNUNET_CONTAINER_multihashmap_get_multiple() themselves s ag...
static void grow(struct GNUNET_CONTAINER_MultiShortmap *map)
Grow the given map to a more appropriate size.
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...
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...
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.
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static char * value
Value of the record to add/remove.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
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.
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
void GNUNET_CONTAINER_multishortmap_iterator_destroy(struct GNUNET_CONTAINER_MultiShortmapIterator *iter)
Destroy a multishortmap iterator.
enum GNUNET_GenericReturnValue 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.
struct GNUNET_CONTAINER_MultiShortmapIterator * GNUNET_CONTAINER_multishortmap_iterator_create(const struct GNUNET_CONTAINER_MultiShortmap *map)
Create an iterator for a multihashmap.
enum GNUNET_GenericReturnValue 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's position.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
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.
GNUNET_CONTAINER_MultiHashMapOption
Options for storing values in the HashMap.
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a 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.
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.
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.
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
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.
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).
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
An entry in the hash map with the full key.
struct BigMapEntry * next
If there is a hash collision, we create a linked list.
void * value
Value of the entry.
struct GNUNET_HashCode key
Key for the entry.
unsigned int next_cache_off
Offset of next_cache entries in use, must be smaller than NEXT_CACHE_SIZE.
unsigned int map_length
Length of the "map" array.
unsigned int modification_counter
Counts the destructive modifications (grow, remove) to the map, so that iterators can check if they a...
union MapEntry * map
All of our buckets.
int use_small_entries
GNUNET_NO if the map entries are of type 'struct BigMapEntry', GNUNET_YES if the map entries are of t...
unsigned int size
Number of entries in the map.
union MapEntry next_cache[16]
Map entries indicating iteration positions currently in use by GNUNET_CONTAINER_multihashmap_get_mult...
unsigned int idx
Current bucket index.
union MapEntry me
Position in the bucket 'idx'.
unsigned int modification_counter
Modification counter as observed on the map when the iterator was created.
const struct GNUNET_CONTAINER_MultiShortmap * map
Map that we are iterating over.
Internal representation of the hash map.
int use_small_entries
GNUNET_NO if the map entries are of type 'struct BigMapEntry', GNUNET_YES if the map entries are of t...
unsigned int map_length
Length of the "map" array.
union MapEntry next_cache[16]
Map entries indicating iteration positions currently in use by GNUNET_CONTAINER_multihashmap_get_mult...
unsigned int size
Number of entries in the map.
unsigned int modification_counter
Counts the destructive modifications (grow, remove) to the map, so that iterators can check if they a...
union MapEntry * map
All of our buckets.
unsigned int next_cache_off
Offset of next_cache entries in use, must be smaller than NEXT_CACHE_SIZE.
A 256-bit hashcode.
An entry in the hash map with just a pointer to the key.
const struct GNUNET_ShortHashCode * key
Key for the entry.
struct SmallMapEntry * next
If there is a hash collision, we create a linked list.
void * value
Value of the entry.
const struct GNUNET_HashCode * key
Key for the entry.
Entry in the map.
struct SmallMapEntry * sme
Variant used if map entries only contain a pointer to the key.
struct BigMapEntry * bme
Variant used if map entries contain the full key.