Class: Puppet::FFI::MemoryPointer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/ffi/windows/api_types.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.from_wide_string(wstr) {|ptr| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a MemoryPointer that points to wide string. This is analogous to the FFI::MemoryPointer.from_string method.

Yields:

  • (ptr)


127
128
129
130
131
132
133
134
135
# File 'lib/puppet/ffi/windows/api_types.rb', line 127

def self.from_wide_string(wstr)
  ptr = FFI::MemoryPointer.new(:uchar, wstr.bytesize + 2)
  ptr.put_array_of_uchar(0, wstr.bytes.to_a)
  ptr.put_uint16(wstr.bytesize, 0)

  yield ptr if block_given?

  ptr
end