a A working stack allocator
Here's an absolutely essential piece of C++
C++ lore, a stack allocator, that will allow you to, say, allocate strings and vectors on the stack. There are 2 stack allocators I know of:
and http://stackoverflow.com/questions/11648202/questions-about-hinnants-stack-allocatorhere .
TroubleThe trouble was, neither of them waswere working with gcc-4.8
gcc-4.8, and both needed fixing. Here's a fixed version of Hinant's allocator. Could there some improvement or fix to still be made?
After running the above example under valgrind
valgrind, it will report:
==25600== HEAP SUMMARY:
==25600== in use at exit: 0 bytes in 0 blocks
==25600== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==25600==
==25600== All heap blocks were freed -- no leaks are possible
==25600==
==25600== For counts of detected and suppressed errors, rerun with: -v
==25600== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
==25600== HEAP SUMMARY: ==25600== in use at exit: 0 bytes in 0 blocks ==25600== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==25600== ==25600== All heap blocks were freed -- no leaks are possible ==25600== ==25600== For counts of detected and suppressed errors, rerun with: -v ==25600== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
a working stack allocator
Here's an absolutely essential piece of C++
lore, a stack allocator, that will allow you to, say, allocate strings and vectors on the stack. There are 2 stack allocators I know of:
http://stackoverflow.com/questions/11648202/questions-about-hinnants-stack-allocator
Trouble was neither of them was working with gcc-4.8
, both needed fixing. Here's a fixed version of Hinant's allocator. Could there some improvement or fix still be made?
After running the above example under valgrind
, it will report:
==25600== HEAP SUMMARY:
==25600== in use at exit: 0 bytes in 0 blocks
==25600== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==25600==
==25600== All heap blocks were freed -- no leaks are possible
==25600==
==25600== For counts of detected and suppressed errors, rerun with: -v
==25600== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
A working stack allocator
Here's an absolutely essential piece of C++ lore, a stack allocator, that will allow you to, say, allocate strings and vectors on the stack. There are 2 stack allocators I know of, here and here .
The trouble was, neither of them were working with gcc-4.8, and both needed fixing. Here's a fixed version of Hinant's allocator. Could there some improvement or fix to still be made?
After running the above example under valgrind, it will report:
==25600== HEAP SUMMARY: ==25600== in use at exit: 0 bytes in 0 blocks ==25600== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==25600== ==25600== All heap blocks were freed -- no leaks are possible ==25600== ==25600== For counts of detected and suppressed errors, rerun with: -v ==25600== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
- 1.9k
- 13
- 22