ubyte to string with @nogc - different behaviors
lucien.perregaux at gmail.com
Wed Aug 5 21:15:10 UTC 2020
On Wednesday, 5 August 2020 at 20:28:22 UTC, Steven Schveighoffer
> But still, you are mallocing a block and throwing it away.
> And I realize, this wouldn't have worked anyway, as str is a
> string, which means you can't overwrite the data.
> I think there is likely a better way to do what you are trying
> to do.
Maybe with a ref parameter, but I think this will only move the
problem outside the function.
> What is the source of the incoming data? Will it be around by
> the time you need to use this string? Can you just slice it
> without copying? I'm not familiar with this code, so I don't
> know the requirements.
> I would think:
> return cast(const(char))buffer[0 .. strnlen(buffer.ptr,
> or something like that.
Will try that.
More information about the Digitalmars-d