Method: ReservedNames::Win32::Memory.local_alloc
- Defined in:
- lib/chef/win32/memory.rb
.local_alloc(length, flags = LPTR, &block) ⇒ Object
local_alloc(length[, flags]) [BLOCK] Allocates memory using LocalAlloc If BLOCK is specified, the memory will be passed to the block and freed afterwards.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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 |