ext/libdeflate/libdeflate_ext.c in libdeflate-0.1.1 vs ext/libdeflate/libdeflate_ext.c in libdeflate-0.2.0

- old
+ new

@@ -133,11 +133,11 @@ } static inline struct libdeflate_compressor * check_compressor(VALUE self) { - return rb_check_typeddata(self, &compressor_data_type); + return rb_check_typeddata(self, &compressor_data_type); } /* * call-seq: * compressor.compress(str, format = DEFLATE, outbuf = nil) -> string @@ -196,11 +196,10 @@ RSTRING_PTR(outbuf), rb_str_capacity(outbuf)); if (out_nbytes > 0) { rb_str_set_len(outbuf, out_nbytes); - OBJ_INFECT(outbuf, str); return outbuf; } max_out_nbytes = compress_bound_func(c, RSTRING_LEN(str)); if (rb_str_capacity(outbuf) >= max_out_nbytes) { @@ -218,11 +217,10 @@ if (out_nbytes == 0) { rb_raise(rb_eLibdefalteError, "failed to compress data"); } rb_str_set_len(outbuf, out_nbytes); - OBJ_INFECT(outbuf, str); return outbuf; } static void @@ -265,38 +263,41 @@ } static inline struct libdeflate_decompressor * check_decompressor(VALUE self) { - return rb_check_typeddata(self, &decompressor_data_type); + return rb_check_typeddata(self, &decompressor_data_type); } static long -next_power_of_two(long n) { - n--; - n |= n >> 1; - n |= n >> 2; - n |= n >> 4; - n |= n >> 8; - n |= n >> 16; +next_power_of_two(long n) +{ + n--; + n |= n >> 1; + n |= n >> 2; + n |= n >> 4; + n |= n >> 8; + n |= n >> 16; #if LONG_MAX > UINT32_MAX - n |= n >> 32; + n |= n >> 32; #endif - n++; - return n; + n++; + return n; } /* * call-seq: * decompressor.decompress(str, format = nil, outbuf = nil) -> string * * Decompresses the given string compressed in <i>format</i>. Valid values of * <i>format</i> are DEFLATE (default), ZLIB and GZIP. If <i>outbuf</i> is * given, the resulting uncompressed data will be written to it. * - * decompressor.decompress("\x01\x03\x00\xFC\xFFfoo") #=> "foo" - * decompressor.decompress("x\x9C\x01\x03\x00\xFC\xFFfoo\x02\x82\x01E", Libdeflate::ZLIB) #=> "foo" + * decompressor.decompress("\x01\x03\x00\xFC\xFFfoo") + * #=> "foo" + * decompressor.decompress("x\x9C\x01\x03\x00\xFC\xFFfoo\x02\x82\x01E", Libdeflate::ZLIB) + * #=> "foo" * * outbuf = 'bar' * decompressor.decompress("\x01\x03\x00\xFC\xFFfoo", nil, outbuf) #=> "foo" * outbuf #=> "foo" */ @@ -354,10 +355,9 @@ } else if (decompress_result != LIBDEFLATE_SUCCESS) { rb_raise(rb_eLibdefalteError, "failed to decompress data"); } rb_str_set_len(outbuf, actual_out_nbytes_ret); - OBJ_INFECT(outbuf, str); return outbuf; } void