特别声明:
建议使用google游览器,火狐也可以
论坛处于测试阶段,一切资料都为测试资料,在论坛正式运行的时候,会尽量保存网友的劳动成果!
HelloWorld论坛秉持互惠互利,共同学习与进步,一个人的梦想大家实现的理想,一直坚持着,望广大网友多多支持,提供宝贵意见
来论坛做什么?
可以先转载你平时学习查找的资料(先论坛查找),自己可以写写体会
把平时碰到的问题,如何解决可以先记录在论坛,以备后来的人学习
可以和会员一起参加一些开源项目的学习,汉化,推广,甚至可以加入团队
|
|
全局的new有六种重载形式,其中placement版本不能重载 void *operator new(std::size_t count)throw(std::bad_alloc); // 一般的版本 void *operator new(std::size_t count,const std::nothrow_t&) throw(); // 兼容早版本的new 内存分配失败不会抛出异常 void *operator new(std::size_t count, void *ptr) throw(); // placement版本 void *operator new[](std::size_t count) throw(std::bad_alloc); // 一般的版本 void *operator new[](std::size_t count,const std::nothrow_t&) throw(); // 兼容早版本的new 内存分配失败不会抛出异常 void *operator new[](std::size_t count, void *ptr) throw(); // placement版本
#ifdef HW_ACE_ALLOCATOR //使用自定义内存管理 hwnet::ManageAllocator<ACE_SYNCH_RECURSIVE_MUTEX>* gManageBlockAllocator; // 一般的版本(plain new) inline void * operator new(size_t size) throw(std::bad_alloc) { if (gManageBlockAllocator == false) { gManageBlockAllocator = hwnet::ManageAllocator<ACE_SYNCH_RECURSIVE_MUTEX>::CreateInstance(1024*16, 512, 512); gManageBlockAllocator->Create(1024*16, sizeof(hwnet::Block)); gManageBlockAllocator->Create(1024*16, 512); ACE_Allocator::instance (dynamic_cast<ACE_Allocator*>(gManageBlockAllocator)); } void* pVoid = gManageBlockAllocator->malloc (size); if (pVoid) { return pVoid; } pVoid = gManageBlockAllocator->malloc (size); static const std::bad_alloc nomem; throw nomem; } //兼容早版本, new内存分配失败不会抛出异常(nothrow new) void *operator new(std::size_t size, const std::nothrow_t& ) throw() { if (gManageBlockAllocator == false) { gManageBlockAllocator = hwnet::ManageAllocator<ACE_SYNCH_RECURSIVE_MUTEX>::CreateInstance(1024*16, 512, 512); gManageBlockAllocator->Create(1024*16, sizeof(hwnet::Block)); gManageBlockAllocator->Create(1024*16, 512); ACE_Allocator::instance (dynamic_cast<ACE_Allocator*>(gManageBlockAllocator)); } return gManageBlockAllocator->malloc (size); } ////placement版本(placement new) //void *operator new(std::size_t count, void *ptr) throw() //{ // return ; //} inline void operator delete(void *p) { return gManageBlockAllocator->free (p); } void *operator new[](std::size_t size) throw(std::bad_alloc) { if (gManageBlockAllocator == false) { gManageBlockAllocator = hwnet::ManageAllocator<ACE_SYNCH_RECURSIVE_MUTEX>::CreateInstance(1024*16, 512, 512); gManageBlockAllocator->Create(1024*16, sizeof(hwnet::Block)); gManageBlockAllocator->Create(1024*16, 512); ACE_Allocator::instance (dynamic_cast<ACE_Allocator*>(gManageBlockAllocator)); } void* pVoid = gManageBlockAllocator->malloc (size); if (pVoid) { return pVoid; } static const std::bad_alloc nomem; throw nomem; } void *operator new[](std::size_t size, const std::nothrow_t&) throw() { if (gManageBlockAllocator == false) { gManageBlockAllocator = hwnet::ManageAllocator<ACE_SYNCH_RECURSIVE_MUTEX>::CreateInstance(1024*16, 512, 512); gManageBlockAllocator->Create(1024*16, sizeof(hwnet::Block)); gManageBlockAllocator->Create(1024*16, 512); ACE_Allocator::instance (dynamic_cast<ACE_Allocator*>(gManageBlockAllocator)); } return gManageBlockAllocator->malloc (size); } //void *operator new[](std::size_t count, void *ptr) throw() //{ // return ; //} inline void operator delete[](void *p) { return gManageBlockAllocator->free (p); } #endif // HW_ACE_ALLOCATOR
|
[审核人]初学MPEG |
|
|
Please Login (or Sign Up) to leave a comment |