Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #7 from eriksoe/master

deserialize() bugfix
  • Loading branch information...
commit 04ff25df26c1f9a4d220eaf38c7ddb710a75a735 2 parents a492bb3 + 2a2b818
Justin Sheehy justinsheehy authored

Showing 2 changed files with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. +3 4 c_src/bloom_filter.hpp
  2. +2 1  src/ebloom.erl
7 c_src/bloom_filter.hpp
@@ -278,12 +278,12 @@ class bloom_filter
278 278
279 279 inline size_t serialized_size() const
280 280 {
281   - return ((table_size_/bits_per_char)+(6*sizeof(size_t))+(salt_.size()*sizeof(bloom_type)));
  281 + return ((table_size_/bits_per_char)+(5*sizeof(size_t) + sizeof(double))+(salt_.size()*sizeof(bloom_type)));
282 282 }
283 283
284   -
285 284 inline void serialize(unsigned char** data, unsigned int* len)
286 285 {
  286 + // TODO: Make this format platform independent!
287 287 size_t buf_sz = serialized_size();
288 288 char *buffer = new char[ buf_sz ];
289 289 serializer s(buffer, buf_sz);
@@ -318,8 +318,7 @@ class bloom_filter
318 318 double desired_false_positive_probability_;
319 319
320 320 serializer s((char*)data, len);
321   - s.clear();
322   - s.read_from_buffer((char*)data, len);
  321 + s.reset();
323 322
324 323 s >> salt_count_;
325 324 s >> table_size_;
3  src/ebloom.erl
@@ -171,7 +171,8 @@ serialize_test() ->
171 171 insert(Ref, <<"abcdef">>),
172 172 Bin3 = serialize(Ref),
173 173 {ok, Ref3} = deserialize(Bin3),
174   - true = contains(Ref3, <<"abcdef">>).
  174 + true = contains(Ref3, <<"abcdef">>),
  175 + false = contains(Ref3, <<"rstuvw">>).
175 176
176 177 clear_test() ->
177 178 {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.