if (arg instanceof RubyString) {
final RubyString s = (RubyString) arg;
final int size = Util.int32Value(s.length());
final ByteList bl = s.getByteList();
final JNAMemoryIO io = JNAMemoryIO.allocateDirect(size);
io.put(0, bl.unsafeBytes(), bl.begin(), bl.length());
io.putByte(bl.length(), (byte) 0);
return new JNABuffer(context.getRuntime(), io, 0, size);
} else {
return allocate(context, arg, CLEAR_DEFAULT);
}