Commit e90c6e32 authored by Wayne Meissner's avatar Wayne Meissner

Correct FFI::AutoPointer.new calls. Fixes headius/spoon#10.

parent 13ba4df2
......@@ -20,14 +20,16 @@ module Spoon
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128
def initialize
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class)
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
error = LibC.posix_spawn_file_actions_init(@pointer)
raise SystemCallError.new("posix_file_actions_init", error) unless error == 0
end
def self.release(ptr)
LibC.posix_spawn_file_actions_destroy(ptr)
LibC.free(ptr)
class Releaser
def self.call(ptr)
LibC.posix_spawn_file_actions_destroy(ptr)
LibC.free(ptr)
end
end
def open(fd, path, oflag, mode)
......@@ -54,14 +56,16 @@ module Spoon
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128
def initialize
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class)
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), Releaser)
error = LibC.posix_spawnattr_init(@pointer)
raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0
end
def self.release(ptr)
LibC.posix_spawnattr_destroy(ptr)
LibC.free(ptr)
class Releaser
def self.call(ptr)
LibC.posix_spawnattr_destroy(ptr)
LibC.free(ptr)
end
end
def pgroup=(group)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment