### 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::ArrayType
- FFI::AutoPointer
- FFI::AutoPointer::CallableReleaser
- FFI::AutoPointer::DefaultReleaser
- FFI::AutoPointer::Releaser
- FFI::ConstGenerator
- FFI::ConstGenerator::Constant
- FFI::DynamicLibrary
- FFI::DynamicLibrary::Symbol
- FFI::Enum
- FFI::Enums
- FFI::Function
- FFI::Generator
- FFI::Generator::Task
- FFI::IO
- FFI::ManagedStruct
- FFI::Platform
- FFI::PlatformError
- FFI::Pointer
- FFI::StrPtrConverter
- FFI::Struct
- FFI::Struct::InlineArray
- FFI::Struct::ManagedStructConverter
- FFI::StructByReference
- FFI::StructByValue
- 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 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.