Is there an easy way to convert a pointer to malloc'd memory to an array?
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed May 25 05:06:58 PDT 2016
On Tuesday, 24 May 2016 at 19:52:17 UTC, Era Scarecrow wrote:
> You can do that??? I thought slices weren't allowed on raw
> pointers. You just blew my mind away!
Slicing and indexing are both allowed (actually, that's a way to
disable bounds checking on an individual expression, see tip:
http://arsdnet.net/this-week-in-d/dec-06.html ) on pointers,
though it isn't considered @safe.
Be careful though: it is still manually managed, so if you pass
it to some function that keeps a slice to your slice, you open
yourself up to a use-after-free bug!
More information about the Digitalmars-d-learn
mailing list