2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2020-06-12 14:21:41 +08:00
|
|
|
|
#ifdef ACL_HOOK_NEW
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
2020-06-12 14:21:41 +08:00
|
|
|
|
# if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
# ifdef NDEBUG
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void* operator new(size_t n);
|
|
|
|
|
void operator delete(void *p);
|
2020-06-12 14:21:41 +08:00
|
|
|
|
# endif
|
|
|
|
|
# else
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#include <new>
|
|
|
|
|
void* operator new(size_t n) throw (std::bad_alloc);
|
|
|
|
|
void operator delete(void *p) throw();
|
2020-06-12 14:21:41 +08:00
|
|
|
|
# endif
|
|
|
|
|
|
2020-06-12 15:14:26 +08:00
|
|
|
|
#elif defined(ACL_CPP_DEBUG_MEM)
|
2020-06-12 14:21:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> acl <EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й¶<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> new/delete
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFB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D><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* ͷ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* #include "acl_cpp/stdlib/malloc.hpp
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱӦʹ<EFBFBD><EFBFBD> NEW <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> new.
|
2020-06-12 14:21:41 +08:00
|
|
|
|
*/
|
2020-06-12 15:37:11 +08:00
|
|
|
|
void* operator new(size_t, const char*, const char*, int) throw();
|
|
|
|
|
void operator delete(void*) throw();
|
|
|
|
|
void operator delete(void*, size_t) throw();
|
2020-06-12 14:21:41 +08:00
|
|
|
|
|
|
|
|
|
#define NEW new(__FILE__, __FUNCTION__, __LINE__)
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2021-01-18 17:14:30 +08:00
|
|
|
|
ACL_CPP_API void mem_checker_start(const char* logfile = NULL);
|
2020-06-12 14:21:41 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ڴ<EFBFBD>״̬<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>߿<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2020-06-13 10:54:34 +08:00
|
|
|
|
ACL_CPP_API void mem_checker_show(void);
|
2020-06-12 14:21:41 +08:00
|
|
|
|
}
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
ACL_CPP_API void acl_slice_init(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>亯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {size_t} <EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijߴ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @param filename {const char*} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param funcname {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param lineno {int} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>abort
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_CPP_API void* acl_new(size_t size, const char* filename,
|
|
|
|
|
const char* funcname, int lineno);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ͷ<EFBFBD><EFBFBD>ڴ溯<EFBFBD><EFBFBD>
|
|
|
|
|
* @param ptr {void*} <EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @param filename {const char*} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param funcname {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param lineno {int} Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_CPP_API void acl_delete(void *ptr, const char* filename,
|
|
|
|
|
const char* funcname, int lineno);
|
|
|
|
|
|
|
|
|
|
}
|