### Home Classes Methods

### In Files

- lib/ffi/autopointer.rb

### Parent

Object

### Methods

- ::new
- #call
- #free

### Files

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

### Class/Module Index

Quicksearch

- FFI
- FFI::AbstractMemory
- FFI::ArrayType
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::Buffer
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::DataConverter
- FFI::DynamicLibrary
- FFI::DynamicLibrary::Symbol
- FFI::Enum
- FFI::Enums
- FFI::Function
- FFI::FunctionType
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::LastError
- FFI::ManagedStruct
- FFI::MemoryPointer
- FFI::NullPointerError
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::ManagedStructConverter
- FFI::StructByReference
- FFI::StructByValue
- FFI::StructGenerator
- FFI::StructGenerator::Field
- FFI::StructLayout
- FFI::StructLayout::Array
- FFI::StructLayout::Enum
- FFI::StructLayout::Field
- FFI::StructLayout::Function
- FFI::StructLayout::InnerStruct
- FFI::StructLayout::Mapped
- FFI::StructLayout::Number
- FFI::StructLayout::Pointer
- FFI::StructLayout::String
- 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 124
    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 143
    def call(*args)
      release(@ptr) if @autorelease && @ptr
    end

free() click to toggle source

@return [nil] Free pointer.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.