peltorator

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

Oct 23rd, 2021
646
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 * ) { }
RAW Paste Data