Why does this allocate? (with example)

probably because you promised a Cstring but a view is a SubString so Julia makes a copy when passing to Ccall. A Cstring is nothing but a pointer to UInt8, so you can replace st in the call with pointer(st), if you need view, you can offset it by pointer(st) + 2 or something.

IIUC, since it’s Cstring, you can’t take arbitrary slices, since they are NULL terminated

2 Likes