diff --git a/.travis.yml b/.travis.yml index cf244d4..fa3139b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,13 @@ rvm: - 1.8.7 - 1.9.2 - 1.9.3 - - rbx + - 2.0.0 + - 2.1.2 + - rbx-2 - ree - - ruby-head - - rbx-18mode - - rbx-19mode matrix: allow_failures: - - rvm: rbx-18mode - - rvm: rbx-19mode + - rvm: rbx-2 script: - bundle exec rake - bundle exec rspec diff --git a/bzip2-ruby.gemspec b/bzip2-ruby.gemspec index f548adc..bcee4ab 100644 --- a/bzip2-ruby.gemspec +++ b/bzip2-ruby.gemspec @@ -16,6 +16,7 @@ Gem::Specification.new do |s| s.test_files = `git ls-files spec`.split("\n") # tests - s.add_development_dependency 'rake-compiler', ">= 0.7.5" - s.add_development_dependency 'rspec', ">= 2.0.0" + s.add_development_dependency 'rake-compiler', '~> 0.8.0' + s.add_development_dependency 'rake', '~> 0.9.3' + s.add_development_dependency 'rspec', '~> 2.8.0' end diff --git a/ext/bzip2/common.c b/ext/bzip2/common.c index dd7e5d5..d845428 100644 --- a/ext/bzip2/common.c +++ b/ext/bzip2/common.c @@ -16,7 +16,7 @@ void bz_free(void *opaque, void *p) { free(p); } -VALUE bz_raise(int error) { +void bz_raise(int error) { VALUE exc; const char *msg; diff --git a/ext/bzip2/common.h b/ext/bzip2/common.h index 5a99b75..5b00420 100644 --- a/ext/bzip2/common.h +++ b/ext/bzip2/common.h @@ -18,20 +18,6 @@ #define DEFAULT_BLOCKS 9 #define ASIZE (1 << CHAR_BIT) -/* Older versions of Ruby (< 1.8.6) need these */ -#ifndef RSTRING_PTR -# define RSTRING_PTR(s) (RSTRING(s)->ptr) -#endif -#ifndef RSTRING_LEN -# define RSTRING_LEN(s) (RSTRING(s)->len) -#endif -#ifndef RARRAY_PTR -# define RARRAY_PTR(s) (RARRAY(s)->ptr) -#endif -#ifndef RARRAY_LEN -# define RARRAY_LEN(s) (RARRAY(s)->len) -#endif - struct bz_file { bz_stream bzs; VALUE in, io; @@ -58,7 +44,6 @@ struct bz_iv { rb_raise(rb_eIOError, "closed IO"); \ } -#ifndef ASDFasdf extern VALUE bz_cWriter, bz_cReader, bz_cInternal; extern VALUE bz_eError, bz_eEOZError; @@ -66,11 +51,10 @@ extern VALUE bz_internal_ary; extern ID id_new, id_write, id_open, id_flush, id_read; extern ID id_closed, id_close, id_str; -#endif void bz_file_mark(struct bz_file * bzf); void* bz_malloc(void *opaque, int m, int n); void bz_free(void *opaque, void *p); -VALUE bz_raise(int err); +void bz_raise(int err); #endif diff --git a/ext/bzip2/reader.c b/ext/bzip2/reader.c index c535799..1953262 100644 --- a/ext/bzip2/reader.c +++ b/ext/bzip2/reader.c @@ -316,7 +316,6 @@ VALUE bz_reader_read(int argc, VALUE *argv, VALUE obj) { OBJ_TAINT(res); } if (n == 0) { - free(bzf->buf); return res; } while (1) { @@ -326,14 +325,12 @@ VALUE bz_reader_read(int argc, VALUE *argv, VALUE obj) { res = rb_str_cat(res, bzf->bzs.next_out, n); bzf->bzs.next_out += n; bzf->bzs.avail_out -= n; - free(bzf->buf); return res; } if (total) { res = rb_str_cat(res, bzf->bzs.next_out, total); } if (bz_next_available(bzf, 0) == BZ_STREAM_END) { - free(bzf->buf); return res; } } @@ -802,8 +799,8 @@ VALUE bz_reader_close(VALUE obj) { Get_BZ2(obj, bzf); if (bzf->buf) { - free(bzf->buf); - bzf->buf = 0; + xfree(bzf->buf); + bzf->buf = NULL; } if (bzf->state == BZ_OK) { BZ2_bzDecompressEnd(&(bzf->bzs)); @@ -837,9 +834,9 @@ VALUE bz_reader_finish(VALUE obj) { Get_BZ2(obj, bzf); if (bzf->buf) { rb_funcall2(obj, id_read, 0, 0); - free(bzf->buf); + xfree(bzf->buf); + bzf->buf = NULL; } - bzf->buf = 0; bzf->state = BZ_OK; return Qnil; }