Skip to content

Commit 5fddc14

Browse files
committed
Use a more direct way for NATIVE_RSTRING_PTR
(cherry picked from commit 39f5275)
1 parent 14fc19f commit 5fddc14

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/cext/include/truffleruby/truffleruby.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int rb_encdb_alias(const char *alias, const char *orig);
158158
VALUE rb_ivar_lookup(VALUE object, const char *name, VALUE default_value);
159159

160160
// Additional macro to make sure the RSTRING_PTR and the bytes are in native memory, for testing.
161-
#define NATIVE_RSTRING_PTR(str) ((char*) polyglot_as_i64(polyglot_invoke(RSTRING_PTR(str), "polyglot_address")))
161+
#define NATIVE_RSTRING_PTR(str) ((char*) polyglot_as_i64(RUBY_CEXT_INVOKE_NO_WRAP("NATIVE_RSTRING_PTR", str)))
162162

163163
// Inline implementations
164164

lib/truffle/truffle/cext.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,6 +1854,10 @@ def RSTRING_PTR(string)
18541854
RStringPtr.new(string)
18551855
end
18561856

1857+
def NATIVE_RSTRING_PTR(string)
1858+
TrufflePrimitive.string_pointer_to_native(string)
1859+
end
1860+
18571861
def RSTRING_END(string)
18581862
RStringEndPtr.new(string)
18591863
end

0 commit comments

Comments
 (0)