Read about our upcoming Code of Conduct on this issue

Commit e652a260 authored by Maciej Fijalkowski's avatar Maciej Fijalkowski
Browse files

A way to get an address from str

parent 04434aa772aa
......@@ -1136,3 +1136,12 @@ c_memcpy = llexternal("memcpy",
from rpython.rtyper.annlowlevel import llstr
from rpython.rtyper.lltypesystem.rstr import STR
def get_buffer_from_str(data):
lldata = llstr(data)
data_start = cast_ptr_to_adr(lldata) + \
offsetof(STR, 'chars') + itemoffsetof(STR.chars, 0)
return cast(CCHARP, data_start)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment