Class: HTS::LibHTS::KString

Inherits:
FFI::Struct show all
Defined in:
lib/hts/libhts/constants.rb

Overview

kstring

Instance Method Summary collapse

Methods inherited from FFI::Struct

struct_layout, union_layout

Instance Method Details

#buffer_ptrObject



16
17
18
# File 'lib/hts/libhts/constants.rb', line 16

def buffer_ptr
  to_ptr.get_pointer(self.class.offset_of(:s))
end

#free_bufferObject



27
28
29
30
31
32
33
34
35
# File 'lib/hts/libhts/constants.rb', line 27

def free_buffer
  ptr = buffer_ptr
  return if ptr.null?

  LibHTS.hts_free(ptr)
  to_ptr.put_pointer(self.class.offset_of(:s), FFI::Pointer::NULL)
  self[:l] = 0
  self[:m] = 0
end

#read_string_copyObject



20
21
22
23
24
25
# File 'lib/hts/libhts/constants.rb', line 20

def read_string_copy
  ptr = buffer_ptr
  return "" if ptr.null?

  ptr.read_string(self[:l])
end