Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.37 KB | None | 0 0
  1. void livingDangerously()
  2. {
  3.     // Access to C's malloc and free primitives
  4.     auto buf = malloc(1024 * 1024);
  5.     scope(exit) free(buf); // free automatically upon scope exit
  6.     // Interprets memory as an array of floats
  7.     auto floats = cast(float[]) buf[0 .. 1024 * 1024];
  8.     // Even stack allocation is possible
  9.     auto moreBuf = alloca(4096 * 100);
  10.     //...
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement