aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util/container_bloomfilter.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c
index 6e8fc7837..3902e4318 100644
--- a/src/util/container_bloomfilter.c
+++ b/src/util/container_bloomfilter.c
@@ -658,6 +658,41 @@ GNUNET_CONTAINER_bloomfilter_or (struct GNUNET_CONTAINER_BloomFilter *bf,
658} 658}
659 659
660/** 660/**
661 * Or the entries of the given raw data array with the
662 * data of the given bloom filter. Assumes that
663 * the size of the data array and the current filter
664 * match.
665 *
666 * @param bf the filter
667 * @param to_or the bloomfilter to or-in
668 * @param size number of bytes in data
669 */
670int
671GNUNET_CONTAINER_bloomfilter_or2 (struct GNUNET_CONTAINER_BloomFilter *bf,
672 const struct GNUNET_CONTAINER_BloomFilter *to_or,
673 size_t size)
674{
675 unsigned int i;
676 unsigned int n;
677 unsigned long long* fc;
678 const unsigned long long* dc;
679
680 if (NULL == bf)
681 return GNUNET_YES;
682 if (bf->bitArraySize != size)
683 return GNUNET_SYSERR;
684 fc = (unsigned long long*) bf->bitArray;
685 dc = (const unsigned long long*) to_or->bitArray;
686 n = size / sizeof (unsigned long long);
687
688 for (i = 0; i < n; i++)
689 fc[i] |= dc[i];
690 for (i = n * sizeof(unsigned long long); i < size; i++)
691 bf->bitArray[i] |= to_or->bitArray[i];
692 return GNUNET_OK;
693}
694
695/**
661 * Remove an element from the filter. 696 * Remove an element from the filter.
662 * 697 *
663 * @param bf the filter 698 * @param bf the filter