Lines Matching refs:pointer

182 ssize_t debug_malloc_backtrace(void* pointer, uintptr_t* frames, size_t frame_count);
184 size_t debug_malloc_usable_size(void* pointer);
186 void debug_free(void* pointer);
189 void* debug_realloc(void* pointer, size_t bytes);
310 static void LogError(const void* pointer, const char* error_str) { in LogError() argument
312 error_log("+++ ALLOCATION %p %s", pointer, error_str); in LogError()
317 PointerData::LogFreeBacktrace(pointer); in LogError()
328 static bool VerifyPointer(const void* pointer, const char* function_name) { in VerifyPointer() argument
330 Header* header = g_debug->GetHeader(pointer); in VerifyPointer()
339 LogError(pointer, error_str.c_str()); in VerifyPointer()
345 if (!PointerData::Exists(pointer)) { in VerifyPointer()
347 LogError(pointer, error_str.c_str()); in VerifyPointer()
354 static size_t InternalMallocUsableSize(void* pointer) { in InternalMallocUsableSize() argument
356 return g_debug->GetHeader(pointer)->usable_size; in InternalMallocUsableSize()
358 return g_dispatch->malloc_usable_size(pointer); in InternalMallocUsableSize()
503 size_t debug_malloc_usable_size(void* pointer) { in debug_malloc_usable_size() argument
506 if (DebugCallsDisabled() || pointer == nullptr) { in debug_malloc_usable_size()
507 return g_dispatch->malloc_usable_size(pointer); in debug_malloc_usable_size()
513 if (!VerifyPointer(pointer, "malloc_usable_size")) { in debug_malloc_usable_size()
517 return InternalMallocUsableSize(pointer); in debug_malloc_usable_size()
522 if ((options & BACKTRACE) && g_debug->pointer->ShouldDumpAndReset()) { in InternalMalloc()
562 void* pointer = result.getValue<void*>(); in InternalMalloc() local
564 if (pointer != nullptr) { in InternalMalloc()
566 PointerData::Add(pointer, size); in InternalMalloc()
570 size_t bytes = InternalMallocUsableSize(pointer); in InternalMalloc()
573 memset(pointer, g_debug->config().fill_alloc_value(), bytes); in InternalMalloc()
600 static TimedResult InternalFree(void* pointer) { in InternalFree() argument
602 if ((options & BACKTRACE) && g_debug->pointer->ShouldDumpAndReset()) { in InternalFree()
611 void* free_pointer = pointer; in InternalFree()
615 header = g_debug->GetHeader(pointer); in InternalFree()
633 bytes = g_dispatch->malloc_usable_size(pointer); in InternalFree()
639 memset(pointer, g_debug->config().fill_free_value(), fill_bytes); in InternalFree()
643 PointerData::Remove(pointer); in InternalFree()
653 pointer = PointerData::AddFreed(pointer, bytes); in InternalFree()
654 if (pointer != nullptr && g_debug->HeaderEnabled()) { in InternalFree()
655 pointer = g_debug->GetHeader(pointer)->orig_pointer; in InternalFree()
657 result = TCALLVOID(free, pointer); in InternalFree()
665 void debug_free(void* pointer) { in debug_free() argument
668 if (DebugCallsDisabled() || pointer == nullptr) { in debug_free()
669 return g_dispatch->free(pointer); in debug_free()
675 if (!VerifyPointer(pointer, "free")) { in debug_free()
679 TimedResult result = InternalFree(pointer); in debug_free()
683 new FreeEntry(pointer, result.GetStartTimeNS(), result.GetEndTimeNS())); in debug_free()
707 void* pointer; in debug_memalign() local
730 pointer = result.getValue<void*>(); in debug_memalign()
731 if (pointer == nullptr) { in debug_memalign()
735 uintptr_t value = reinterpret_cast<uintptr_t>(pointer) + g_debug->pointer_offset(); in debug_memalign()
741 pointer = InitHeader(header, pointer, bytes); in debug_memalign()
750 pointer = result.getValue<void*>(); in debug_memalign()
753 if (pointer != nullptr) { in debug_memalign()
755 PointerData::Add(pointer, bytes); in debug_memalign()
759 size_t bytes = InternalMallocUsableSize(pointer); in debug_memalign()
762 memset(pointer, g_debug->config().fill_alloc_value(), bytes); in debug_memalign()
766 g_debug->record->AddEntry(new MemalignEntry(pointer, bytes, alignment, in debug_memalign()
771 return pointer; in debug_memalign()
774 void* debug_realloc(void* pointer, size_t bytes) { in debug_realloc() argument
778 return g_dispatch->realloc(pointer, bytes); in debug_realloc()
784 if (pointer == nullptr) { in debug_realloc()
790 pointer = result.getValue<void*>(); in debug_realloc()
791 return pointer; in debug_realloc()
794 if (!VerifyPointer(pointer, "realloc")) { in debug_realloc()
799 TimedResult result = InternalFree(pointer); in debug_realloc()
802 g_debug->record->AddEntry(new ReallocEntry(nullptr, bytes, pointer, result.GetStartTimeNS(), in debug_realloc()
829 Header* header = g_debug->GetHeader(pointer); in debug_realloc()
833 PointerData::Remove(pointer); in debug_realloc()
834 PointerData::Add(pointer, real_size); in debug_realloc()
836 return pointer; in debug_realloc()
851 PointerData::Remove(pointer); in debug_realloc()
852 PointerData::Add(pointer, real_size); in debug_realloc()
854 return pointer; in debug_realloc()
866 memcpy(new_pointer, pointer, prev_size); in debug_realloc()
867 TimedResult free_time = InternalFree(pointer); in debug_realloc()
873 PointerData::Remove(pointer); in debug_realloc()
876 prev_size = g_dispatch->malloc_usable_size(pointer); in debug_realloc()
877 result = TCALL(realloc, pointer, real_size); in debug_realloc()
900 g_debug->record->AddEntry(new ReallocEntry(new_pointer, bytes, pointer, result.GetStartTimeNS(), in debug_realloc()
940 void* pointer; in debug_calloc() local
950 pointer = InitHeader(header, header, size); in debug_calloc()
953 pointer = result.getValue<void*>(); in debug_calloc()
958 new CallocEntry(pointer, nmemb, bytes, result.GetStartTimeNS(), result.GetEndTimeNS())); in debug_calloc()
961 if (pointer != nullptr && g_debug->TrackPointers()) { in debug_calloc()
962 PointerData::Add(pointer, size); in debug_calloc()
964 return pointer; in debug_calloc()
1044 PointerData::IteratePointers([&callback, &arg](uintptr_t pointer) { in debug_malloc_iterate() argument
1045 callback(pointer, InternalMallocUsableSize(reinterpret_cast<void*>(pointer)), arg); in debug_malloc_iterate()
1058 if (g_debug->pointer) { in debug_malloc_disable()
1059 g_debug->pointer->PrepareFork(); in debug_malloc_disable()
1065 if (g_debug->pointer) { in debug_malloc_enable()
1066 g_debug->pointer->PostForkParent(); in debug_malloc_enable()
1071 ssize_t debug_malloc_backtrace(void* pointer, uintptr_t* frames, size_t max_frames) { in debug_malloc_backtrace() argument
1072 if (DebugCallsDisabled() || pointer == nullptr) { in debug_malloc_backtrace()
1082 pointer = UntagPointer(pointer); in debug_malloc_backtrace()
1083 return PointerData::GetFrames(pointer, frames, max_frames); in debug_malloc_backtrace()