### Home Classes Methods

### In Files

- lib/ffi/autopointer.rb

### Parent

Object

### Methods

- ::new
- #autorelease=
- #call
- #free

### Files

- History.txt
- README.rdoc

### 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}.

### 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 106
    def initialize(ptr, proc)
      @ptr = ptr
      @proc = proc
      @autorelease = true
    end

### Public Instance Methods

autorelease=(autorelease) click to toggle source

@param [Boolean] autorelease @return [Boolean] autorelease Set `autorelease` attribute for pointer managed by Releaser.

    # File lib/ffi/autopointer.rb, line 126
    def autorelease=(autorelease)
      @autorelease = autorelease if @ptr
    end

call(*args) click to toggle source

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

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

free() click to toggle source

@return [nil] Free pointer.

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.