add memattr to memory of glibc_malloc

This commit is contained in:
tushicheng
2023-05-18 13:18:37 +00:00
committed by ob-robot
parent 9d3fa298b7
commit 80ee109d1c
2 changed files with 32 additions and 2 deletions

View File

@ -12,7 +12,7 @@
#ifndef MALLOC_HOOK_H
#define MALLOC_HOOK_H
#include "lib/alloc/alloc_struct.h"
extern void init_malloc_hook();
inline bool& in_hook()
@ -20,5 +20,31 @@ inline bool& in_hook()
thread_local bool in_hook = false;
return in_hook;
}
namespace oceanbase
{
namespace lib
{
class ObMallocHookAttrGuard
{
public:
ObMallocHookAttrGuard(ObMemAttr& attr)
: old_attr_(tl_mem_attr)
{
tl_mem_attr = attr;
}
~ObMallocHookAttrGuard()
{
tl_mem_attr = old_attr_;
}
static ObMemAttr get_tl_mem_attr()
{
return tl_mem_attr;
}
private:
static thread_local ObMemAttr tl_mem_attr;
ObMemAttr old_attr_;
};
}
}
#endif /* MALLOC_HOOK_H */