Hello

How do I do the equivalent of the code below in a C extension?

def foo(&block)
  x = 0
  my_iterator do |b|
    b.process(&block)
    x += 1
  end
  return x
end

I tried lots of different combinations of rb_iterate() and rb_proc_new()
but it turned into one big mess :s

Thanks,
Andre