#dbugfix 15136

Adam D. Ruppe destructionator at gmail.com
Sat Jan 19 01:08:52 UTC 2019


On Friday, 18 January 2019 at 23:26:07 UTC, Dennis wrote:
> In arsd/simpledisplay.d, toStringz is simply defined as:
>
> ```
> const(char)* toStringz(string s) { return (s ~ '\0').ptr; }
> ```

That definition is still in my code, but there are no more uses - 
I've replaced every instance of it with either calls to C 
functions that take a pointer+length combo anyway, or by copying 
into local buffers made out of static arrays. (Notably on 
Windows, there is a WCharzBuffer struct that can also do wchar 
and cr/lf conversions too.)

But, yeah, the s ~ 0 .ptr is a really easy way to do it basically 
right most the time. Just as long as the C function doesn't store 
it! (but then the local buffer is broken too so separate issue)


More information about the Digitalmars-d mailing list