class Chef::ReservedNames::Win32::Memory

Public Class Methods

local_alloc(length, flags = LPTR) { |result| ... } click to toggle source

local_alloc(length[, flags]) [BLOCK] Allocates memory using LocalAlloc If BLOCK is specified, the memory will be passed to the block and freed afterwards.

# File lib/chef/win32/memory.rb, line 32
def self.local_alloc(length, flags = LPTR, &block)
  result = LocalAlloc(flags, length)
  if result.null?
    Chef::ReservedNames::Win32::Error.raise!
  end
  # If a block is passed, handle freeing the memory at the end
  if !block.nil?
    begin
      yield result
    ensure
      local_free(result)
    end
  else
    result
  end
end
local_discard(pointer) click to toggle source

local_discard(pointer) Discard memory. Equivalent to local_realloc(pointer, 0)

# File lib/chef/win32/memory.rb, line 51
def self.local_discard(pointer)
  local_realloc(pointer, 0, LMEM_MOVEABLE)
end
local_flags(pointer) click to toggle source

local_flags(pointer) Get lock count and Windows flags for local_alloc allocated memory. Use: flags, lock_count = local_flags(pointer)

# File lib/chef/win32/memory.rb, line 58
def self.local_flags(pointer)
  result = LocalFlags(pointer)
  if result == LMEM_INVALID_HANDLE
    Chef::ReservedNames::Win32::Error.raise!
  end
  [ result & ~LMEM_LOCKCOUNT, result & LMEM_LOCKCOUNT ]
end
local_free(pointer) click to toggle source

local_free(pointer) Free memory allocated using local_alloc

# File lib/chef/win32/memory.rb, line 68
def self.local_free(pointer)
  result = LocalFree(pointer)
  unless result.null?
    Chef::ReservedNames::Win32::Error.raise!
  end
end
local_free_finalizer(pointer) click to toggle source
# File lib/chef/win32/memory.rb, line 95
def self.local_free_finalizer(pointer)
  proc { local_free(pointer) }
end
local_realloc(pointer, size, flags = LMEM_MOVEABLE | LMEM_ZEROINIT) click to toggle source

local_realloc(pointer, size[, flags]) Resizes memory allocated using LocalAlloc.

# File lib/chef/win32/memory.rb, line 77
def self.local_realloc(pointer, size, flags = LMEM_MOVEABLE | LMEM_ZEROINIT)
  result = LocalReAlloc(pointer, size, flags)
  if result.null?
    Chef::ReservedNames::Win32::Error.raise!
  end
  result
end
local_size(pointer) click to toggle source

local_size(pointer) Gets the size of memory allocated using LocalAlloc.

# File lib/chef/win32/memory.rb, line 87
def self.local_size(pointer)
  result = LocalSize(pointer)
  if result == 0
    Chef::ReservedNames::Win32::Error.raise!
  end
  result
end