schmurfy/mruby-rubyffi-compat — pull request #3 by ppibburr (2013-06-03 04:01:07+00:00)
Title: fix segfaults on read and writes

Pointers created from the FFI::Pointer (FFI::MemoryPointer) work fine.
However when wrapping from `Pointer::refer` segfaults occur.

Example of segfault:
```ruby
int = CFunc::Int.new
ptr = FFI::Pointer.refer(int.addr)
ptr.write_int 2
raise unless ptr.read_int == 2
```

Its due to `FFI::Pointer#write_type` and `FFI::Pointer#read_type`
When using:
- `CFunc::Pointer(type)::set`
- `CFunc::Pointer(type)::get`
- `CFunc::Pointer(type)::refer`

the code should be like as demonstrated in mruby-cfunc tests:
```ruby
int = CFunc::Int.new()
int_ptr = int.addr
CFunc::Int.set(int_ptr,6)
CFunc::Int.get(int_ptr) #=> 6
```