Sha256: 135654a21849f10065b3861557ae41246ec3b88d4e9d75284857ef54892aff55
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module ICU module Lib module Util def self.read_null_terminated_array_of_strings(pointer) offset = 0 result = [] while (ptr = pointer.get_pointer(offset)) != FFI::Pointer::NULL do result << ptr.read_string offset += FFI::Pointer.size end result end def self.read_string_buffer(length) attempts = 0 begin result = FFI::MemoryPointer.new(:char, length) Lib.check_error { |status| length = yield result, status } rescue BufferOverflowError attempts += 1 retry if attempts < 2 raise BufferOverflowError, "needed: #{length}" end result.read_string(length) end def self.read_uchar_buffer(length) attempts = 0 begin result = UCharPointer.new(length) Lib.check_error { |status| length = yield result, status } rescue BufferOverflowError attempts += 1 retry if attempts < 2 raise BufferOverflowError, "needed: #{length}" end result.string(length) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffi-icu-0.1.0 | lib/ffi-icu/lib/util.rb |