Hello,
Theres a lot of problems with the implementation because the init function allocates a small amount of memory and later in the execution I call bloom_free().
Since implementing this, if I restart nginx, it fails to restart the first time and I have to call nginx start to make sure the server comes back up.
I'm assuming this is because many instances of the bloom object are never free'd?
My long term plan is to modify the library to handle memory allocation from FFI directly, but I don't have time to do it right now.
Is this normal behavior? Is there a simple work around?
ffi.cdef[[
typedef struct {
int entries;
double error;
int bits;
int bytes;
int hashes;
double bpe;
unsigned char * bf;
int ready;
} bloom_t;
int bloom_init(bloom_t * bloom, int entries, double error);
int bloom_check(bloom_t * bloom, const void * buffer, int len);
int bloom_add(bloom_t * bloom, const void * buffer, int len);
void bloom_print(bloom_t * bloom);
void bloom_free(bloom_t * bloom);
]]
lib = ffi.load("libbloom.so")
self:filterObj = ffi.new("bloom_t")
lib.bloom_init(self:filterObj, ...)
...
lib.bloom_free(self:filterObj)