#include "dynarray.h" DECL_MAIN { // Reserving 16GiB. auto a = Arena(16ULL * 1024ULL * 1024ULL * 1024ULL); // Committing a full page to make space for 4 bytes (with some headroom). bool committed = a.Grow(4); assert(committed); a.base[0] = 'a'; a.base[1] = 'b'; a.base[2] = 'c'; a.base[4] = '\0'; std::cout << a.base << std::endl; // Past the declared length, but still in committed memory. // No segfault, but in real code it's probably a bug. a.base[5] = 'x'; a.base[kBytesPerCommit-1] = 'y'; // Reserved, but not committed memory. Segfault. // a.base[kBytesPerCommit] = 'x'; return 0; }