Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void livingDangerously()
- {
- // Access to C's malloc and free primitives
- auto buf = malloc(1024 * 1024);
- scope(exit) free(buf); // free automatically upon scope exit
- // Interprets memory as an array of floats
- auto floats = cast(float[]) buf[0 .. 1024 * 1024];
- // Even stack allocation is possible
- auto moreBuf = alloca(4096 * 100);
- //...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement