Advertisement
peltorator

Быстрая аллокация памяти

Oct 23rd, 2021
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. const int MAX_MEM = 1e8;
  2. int mpos = 0;
  3. char mem[MAX_MEM];
  4. inline void * operator new ( size_t n ) {
  5.     char *res = mem + mpos; mpos += n;
  6.     assert(mpos <= MAX_MEM);
  7.     return (void *)res;
  8. }
  9. inline void operator delete ( void * ) { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement