lib/ffi/hiredis_vip/sscan.rb in ffi-hiredis_vip-0.1.0.pre3 vs lib/ffi/hiredis_vip/sscan.rb in ffi-hiredis_vip-0.1.0.pre4
- old
+ new
@@ -31,10 +31,12 @@
# TODO: more error checking here?
case reply[:type]
when :REDIS_REPLY_ARRAY
[ scan_results_cursor(reply), scan_results_to_array(reply) ]
end
+ ensure
+ ::FFI::HiredisVip::Core.freeReplyObject(reply.pointer) if reply
end
def supports_sscan?
true
end
@@ -43,11 +45,11 @@
def scan_results_cursor(reply)
zeroth_result = ::FFI::HiredisVip::Core.redisReplyElement(reply, 0)
if !zeroth_result.null? && zeroth_result[:type] == :REDIS_REPLY_STRING
- zeroth_result[:str]
+ zeroth_result[:str].dup
else
raise "probs" # TODO: what do we do here
end
end
@@ -56,10 +58,10 @@
array_reply = ::FFI::HiredisVip::Core.redisReplyElement(reply, 1)
if !array_reply.null? && array_reply[:type] == :REDIS_REPLY_ARRAY
0.upto(array_reply[:elements] - 1) do |element_number|
result = ::FFI::HiredisVip::Core.redisReplyElement(array_reply, element_number)
- scan_results << result[:str] if result[:type] == :REDIS_REPLY_STRING
+ scan_results << result[:str].dup if result[:type] == :REDIS_REPLY_STRING
end
scan_results
else
raise "probs" # TODO: what do we do here