Skip to content
Browse files

Merge pull request #7 from eriksoe/master

deserialize() bugfix
  • Loading branch information...
2 parents a492bb3 + 2a2b818 commit 04ff25df26c1f9a4d220eaf38c7ddb710a75a735 @justinsheehy justinsheehy committed Jan 10, 2012
Showing with 5 additions and 5 deletions.
  1. +3 −4 c_src/bloom_filter.hpp
  2. +2 −1 src/ebloom.erl
View
7 c_src/bloom_filter.hpp
@@ -278,12 +278,12 @@ class bloom_filter
inline size_t serialized_size() const
{
- return ((table_size_/bits_per_char)+(6*sizeof(size_t))+(salt_.size()*sizeof(bloom_type)));
+ return ((table_size_/bits_per_char)+(5*sizeof(size_t) + sizeof(double))+(salt_.size()*sizeof(bloom_type)));
}
-
inline void serialize(unsigned char** data, unsigned int* len)
{
+ // TODO: Make this format platform independent!
size_t buf_sz = serialized_size();
char *buffer = new char[ buf_sz ];
serializer s(buffer, buf_sz);
@@ -318,8 +318,7 @@ class bloom_filter
double desired_false_positive_probability_;
serializer s((char*)data, len);
- s.clear();
- s.read_from_buffer((char*)data, len);
+ s.reset();
s >> salt_count_;
s >> table_size_;
View
3 src/ebloom.erl
@@ -171,7 +171,8 @@ serialize_test() ->
insert(Ref, <<"abcdef">>),
Bin3 = serialize(Ref),
{ok, Ref3} = deserialize(Bin3),
- true = contains(Ref3, <<"abcdef">>).
+ true = contains(Ref3, <<"abcdef">>),
+ false = contains(Ref3, <<"rstuvw">>).
clear_test() ->
{ok, Ref} = new(5, 0.01, 123),

0 comments on commit 04ff25d

Please sign in to comment.
Something went wrong with that request. Please try again.