Skip to content

Commit

Permalink
clean up gcc warnings. version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfryed committed Jan 21, 2013
1 parent c6ccefc commit 5e385f4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG
@@ -1,3 +1,15 @@
=== 0.2.1 (2013-01-21)

* Clean up compiler warnings.

=== 0.2.0 (2012-04-27)

* Added BloomFilter#bits

=== 0.1.1 (2012-01-26)

* Store table size in dumps.

=== 0.1.0 (2012-01-25)

* Initial version.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -52,10 +52,10 @@ BloomFilter is a ruby library that implements an in-memory [Bloom Filter](http:/

[https://github.com/igrigorik/bloomfilter-rb](https://github.com/igrigorik/bloomfilter-rb)

## License

[Creative Commons Attribution - CC BY](http://creativecommons.org/licenses/by/3.0)

## Home Page

[https://github.com/deepfryed/bloom-filter](https://github.com/deepfryed/bloom-filter)

## License

MIT
4 changes: 2 additions & 2 deletions bloom-filter.gemspec
Expand Up @@ -2,11 +2,11 @@

Gem::Specification.new do |s|
s.name = "bloom-filter"
s.version = "0.2.0"
s.version = "0.2.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Bharanee Rathna"]
s.date = "2012-04-27"
s.date = "2013-01-21"
s.description = "A fast Bloom Filter library for Ruby for unices."
s.email = ["deepfryed@gmail.com"]
s.extensions = ["ext/extconf.rb"]
Expand Down
24 changes: 15 additions & 9 deletions ext/bloom_filter.c
Expand Up @@ -79,6 +79,7 @@ VALUE bloom_initialize(int argc, VALUE *argv, VALUE self) {
rb_raise(rb_eNoMemError, "unable to allocate memory for BloomFilter");

DATA_PTR(self) = filter;
return self;
}


Expand All @@ -95,12 +96,13 @@ VALUE bloom_include(VALUE klass, VALUE string) {

VALUE bloom_dump(VALUE klass, VALUE file) {
int fd;
void *buffer;
uint64_t nbits;
FileHeader header;
BloomFilter *filter = bloom_handle(klass);

nbits = (filter->table_size + 7) / 8;
void *buffer = malloc(nbits);
nbits = (filter->table_size + 7) / 8;
buffer = malloc(nbits);

if (!buffer)
rb_raise(rb_eNoMemError, "out of memory dumping BloomFilter");
Expand Down Expand Up @@ -139,12 +141,14 @@ VALUE bloom_dump(VALUE klass, VALUE file) {
VALUE bloom_bits(VALUE klass) {
BloomFilter *filter = bloom_handle(klass);

int i = 0;
int nbits = filter->table_size;
char buffer[nbits];

VALUE bitmap;
char *buffer;
unsigned char b;
int bit;
int i = 0, bit, nbits = filter->table_size;

buffer = (char *)malloc(nbits);
if (!buffer)
rb_raise(rb_eNoMemError, "out of memory dumping BloomFilter");

for (i = 0; i < nbits; i++) {
b = filter->table[i / 8];
Expand All @@ -156,7 +160,9 @@ VALUE bloom_bits(VALUE klass) {
buffer[i] = '1';
}

return rb_str_new(buffer, nbits);
bitmap = rb_str_new(buffer, nbits);
free(buffer);
return bitmap;
}

VALUE bloom_load(VALUE klass, VALUE file) {
Expand Down Expand Up @@ -199,7 +205,7 @@ VALUE bloom_load(VALUE klass, VALUE file) {
return instance;
}

Init_bloom_filter() {
void Init_bloom_filter() {
VALUE cBloom = rb_define_class("BloomFilter", rb_cObject);

rb_define_method(cBloom, "initialize", RUBY_METHOD_FUNC(bloom_initialize), -1);
Expand Down
2 changes: 1 addition & 1 deletion ext/version.h
@@ -1 +1 @@
#define RUBY_BLOOM_FILTER_VERSION "0.2.0"
#define RUBY_BLOOM_FILTER_VERSION "0.2.1"

0 comments on commit 5e385f4

Please sign in to comment.