3 ms·
> you can use a pointer to str_buf anywhere a function calls for a pointer to str Yes, you could, but I see no function mentioned in TFA that wants a pointer t
by teo_zero 2y ago
> you can use a pointer to str_buf anywhere a function calls for a pointer to str
Yes, you could, but I see no function mentioned in TFA that wants a pointer to str, only functions that want a str: print_str(), print_fmt(), com_write(). At the same time, the functions that return strings return a struct, never a pointer: str_new(), str_from_range(), str_from_buf(), fmt_buf_new(), and the pseudo-function STR().
To use the memory layout trick you should go through reference + cast + dereference:
*((struct str *)&...)
My question still holds: is the code littered by such conversion artifacts?