Method: FFI::AbstractMemory#put_string
- Defined in:
- ext/ffi_c/AbstractMemory.c
#put_string(offset, str) ⇒ self
Put a string in memory.
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'ext/ffi_c/AbstractMemory.c', line 516 static VALUE memory_put_string(VALUE self, VALUE offset, VALUE str) { AbstractMemory* ptr = MEMORY(self); long off, len; Check_Type(str, T_STRING); off = NUM2LONG(offset); len = RSTRING_LEN(str); checkWrite(ptr); checkBounds(ptr, off, len + 1); memcpy(ptr->address + off, RSTRING_PTR(str), len); *((char *) ptr->address + off + len) = '\0'; return self; } |