add memattr to memory of glibc_malloc
This commit is contained in:
28
deps/oblib/src/lib/alloc/malloc_hook.h
vendored
28
deps/oblib/src/lib/alloc/malloc_hook.h
vendored
@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user