summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2013-11-18 20:32:04 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2013-11-18 20:32:04 -0800
commitd783ff728672f64746f20cc5475120ca2d26c537 (patch)
treea203b2eca3cd5a255426701bcd8ac7e7d4456e21
parent47905bd4cef721bf5de4e3fc4e9411665414d4ff (diff)
downloadffi-yajl-d783ff728672f64746f20cc5475120ca2d26c537.tar.gz
fix nasty segfaul bugs, don't need yajl-exclusion
-rw-r--r--lib/ffi_yajl.rb19
-rwxr-xr-xlib/ffi_yajl/ext/encoder.bundlebin10484 -> 15516 bytes
-rw-r--r--lib/ffi_yajl/ffi/encoder.rb5
3 files changed, 8 insertions, 16 deletions
diff --git a/lib/ffi_yajl.rb b/lib/ffi_yajl.rb
index 9452bfb..1a38079 100644
--- a/lib/ffi_yajl.rb
+++ b/lib/ffi_yajl.rb
@@ -13,19 +13,12 @@ module FFI_Yajl
@opts = opts
end
- if defined?(Yajl)
- puts "oh shit, yajl is loaded, don't cross the streams, going ffi.."
+ begin
+ require 'ffi_yajl/ext'
+ include FFI_Yajl::Ext::Encoder
+ rescue LoadError
require 'ffi_yajl/ffi'
include FFI_Yajl::FFI::Encoder
- else
- begin
- require 'ffi_yajl/ext'
- puts "W00T! native extensions!"
- include FFI_Yajl::Ext::Encoder
- rescue LoadError
- require 'ffi_yajl/ffi'
- include FFI_Yajl::FFI::Encoder
- end
end
end
end
@@ -116,8 +109,8 @@ module FFI_Yajl
attach_function :yajl_gen_config, [:yajl_gen, :yajl_gen_option, :varargs], :int
- # yajl_gen yajl_gen_alloc (const yajl_gen_config *config, const yajl_alloc_funcs *allocFuncs)
- attach_function :yajl_gen_alloc, [:pointer, :pointer], :yajl_gen
+ # yajl_gen yajl_gen_alloc (const yajl_alloc_funcs *allocFuncs)
+ attach_function :yajl_gen_alloc, [:pointer], :yajl_gen
# yajl_gen yajl_gen_alloc2 (const yajl_print_t callback, const yajl_gen_config *config, const yajl_alloc_funcs *allocFuncs, void *ctx)
# attach_function :yajl_gen_alloc2, [:pointer, :pointer, :pointer, :pointer], :yajl_gen
# void yajl_gen_free (yajl_gen handle)
diff --git a/lib/ffi_yajl/ext/encoder.bundle b/lib/ffi_yajl/ext/encoder.bundle
index 169d970..d05e342 100755
--- a/lib/ffi_yajl/ext/encoder.bundle
+++ b/lib/ffi_yajl/ext/encoder.bundle
Binary files differ
diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb
index 17e8787..7798f8d 100644
--- a/lib/ffi_yajl/ffi/encoder.rb
+++ b/lib/ffi_yajl/ffi/encoder.rb
@@ -34,10 +34,9 @@ module FFI_Yajl
length = length_ptr.read_int
string = string_ptr.get_pointer(0).read_string
- return string
- ensure
- # free up the yajl encoder
FFI_Yajl.yajl_gen_free(yajl_gen)
+
+ return string
end
end
end