    # File lib/ffi/autopointer.rb, line 59
        def initialize(ptr, proc=nil, &block)
          raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) \
            || ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer)

          @releaser = if proc
                        raise RuntimeError.new("proc must be callable") unless proc.respond_to?(:call)
                        CallableReleaser.new(ptr, proc)

                      else
                        raise RuntimeError.new("no release method defined") unless self.class.respond_to?(:release)
                        DefaultReleaser.new(ptr, self.class)
                      end

          self.parent = ptr
          ObjectSpace.define_finalizer(self, @releaser)
          self
        end