• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "memory_trace.h"
2 #ifdef HOOK_ENABLE
3 #include "common_def.h"
4 #include "musl_preinit_common.h"
5 #endif
6 
memtrace(void * addr,size_t size,const char * tag,bool is_using)7 void memtrace(void* addr, size_t size, const char* tag, bool is_using)
8 {
9 #ifdef HOOK_ENABLE
10 	volatile const struct MallocDispatchType* dispatch_table = (struct MallocDispatchType *)atomic_load_explicit(
11 		&__musl_libc_globals.current_dispatch_table, memory_order_acquire);
12 	if (__predict_false(dispatch_table != NULL)) {
13 		if (__get_memleak_hook_flag()) {
14 			return;
15 		}
16 		if (!__get_global_hook_flag()) {
17 			return;
18 		}
19 		else if (!__get_hook_flag()) {
20 			return;
21 		}
22 		return dispatch_table->memtrace(addr, size, tag, is_using);
23 	}
24 #endif
25     return;
26 }
27