Skip to content

Commit

Permalink
AutoPointer does not support classes in ffi gem
Browse files Browse the repository at this point in the history
FFI gem (for MRI) does not support passing classes for deallocator. Use
pass unbound method, since it's supported by both rubies.
  • Loading branch information
libc committed Dec 26, 2012
1 parent 9eceb36 commit 4454035
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/spoon/unix.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class FileActions
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128 SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 128


def initialize def initialize
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class) @pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class.method(:release))
error = LibC.posix_spawn_file_actions_init(@pointer) error = LibC.posix_spawn_file_actions_init(@pointer)
raise SystemCallError.new("posix_file_actions_init", error) unless error == 0 raise SystemCallError.new("posix_file_actions_init", error) unless error == 0
end end
Expand Down Expand Up @@ -42,7 +42,7 @@ class SpawnAttributes
SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 336 SIZE = FFI::Platform.mac? ? FFI.type_size(:pointer) : 336


def initialize def initialize
@pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class) @pointer = FFI::AutoPointer.new(LibC.malloc(SIZE), self.class.method(:release))
error = LibC.posix_spawnattr_init(@pointer) error = LibC.posix_spawnattr_init(@pointer)
raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0 raise SystemCallError.new("posix_spawnattr_init", error) unless error == 0
end end
Expand Down

0 comments on commit 4454035

Please sign in to comment.