### Home Classes Methods

### In Files

- lib/ffi/autopointer.rb

### Parent

Object

### Methods

- ::new
- #call
- #free

### Files

- Makefile
- ChangeLog
- LICENSE
- README
- compile
- configure
- depcomp
- stamp-vti
- install-sh
- libtool-version
- mdate-sh
- missing

### Class/Module Index

Quicksearch

- FFI
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::Enum
- FFI::Enums
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::Library
- FFI::ManagedStruct
- FFI::NotFoundError
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::ManagedStructConverter
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Enum
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayoutBuilder
- FFI::TypesGenerator
- FFI::Union
- FFI::VariadicInvoker

No matching classes.

# FFI::AutoPointer::Releaser

@abstract Base class for {AutoPointer}'s releasers.

    All subclasses of Releaser should define a +#release(ptr)+ method.

A releaser is an object in charge of release an {AutoPointer}.

### Attributes

autorelease[RW]

### Public Class Methods

new(ptr, proc) click to toggle source

@param [Pointer] ptr @param [call] proc @return [nil] A new instance of Releaser.

    # File lib/ffi/autopointer.rb, line 114
    def initialize(ptr, proc)
      @ptr = ptr
      @proc = proc
      @autorelease = true
    end

### Public Instance Methods

call(*args) click to toggle source

@param args Release pointer if `autorelease` is set.

    # File lib/ffi/autopointer.rb, line 133
    def call(*args)
      release(@ptr) if @autorelease && @ptr
    end

free() click to toggle source

@return [nil] Free pointer.

    # File lib/ffi/autopointer.rb, line 122
    def free
      if @ptr
        release(@ptr)
        @autorelease = false
        @ptr = nil
        @proc = nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.