📄 local_new.cpp
字号:
#include <stdio.h>
#include <stdlib.h>
/** \file
This file contains overrides for the global new and delete
operators. These exist to assure that only the pool allocation
functions are called. If you see a message from one of these
functions then something other than pool allocation is taking
place.
This file is only used for testing. If you don't want to do this
check you can remove this file from the software build.
*/
void *operator new( size_t num_bytes )
{
printf("global operator new\n");
void *rtn = malloc( num_bytes );
return rtn;
} // new
void *operator new[]( size_t num_bytes )
{
printf("global operator new []\n");
void *rtn = malloc( num_bytes );
return rtn;
}
void operator delete( void *addr )
{
printf("global operator delete\n");
free( addr );
}
void operator delete[](void *addr )
{
printf("global operator delete []\n");
free( addr );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -