MCPcopy Create free account
hub / github.com/adny-code/fastgrind / __wrap_realloc

Function __wrap_realloc

include/fastgrind.h:1705–1756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1703 }
1704
1705 MEM_NO_INSTRUMENT MEM_INLINE_USED inline void *__wrap_realloc(void *ptr, size_t size)
1706 {
1707 if (__mem_in_probe_)
1708 {
1709 #if defined(FASTGRIND_TC_MALLOC)
1710 return tc_realloc(ptr, size);
1711 #elif defined(FASTGRIND_JE_MALLOC)
1712 return je_realloc_emulate(ptr, size);
1713 #else
1714 return __real_realloc(ptr, size);
1715 #endif
1716 }
1717
1718 __mem_in_probe_ = true;
1719
1720 size_t old_size = ptr ? malloc_usable_size(ptr) : 0;
1721 if (size == 0 && ptr)
1722 {
1723 if (old_size)
1724 memLocalInfo::instance().sub(old_size);
1725
1726 #if defined(FASTGRIND_TC_MALLOC)
1727 tc_free(ptr);
1728 #elif defined(FASTGRIND_JE_MALLOC)
1729 je_free_default(ptr);
1730 #else
1731 __real_free(ptr);
1732 #endif
1733
1734 __mem_in_probe_ = false;
1735 return nullptr;
1736 }
1737
1738 void *p = nullptr;
1739 #if defined(FASTGRIND_TC_MALLOC)
1740 p = tc_realloc(ptr, size);
1741 #elif defined(FASTGRIND_JE_MALLOC)
1742 p = je_realloc_emulate(ptr, size);
1743 #else
1744 p = __real_realloc(ptr, size);
1745 #endif
1746
1747 if (p)
1748 {
1749 if (ptr && old_size)
1750 memLocalInfo::instance().sub(old_size);
1751 memLocalInfo::instance().add(malloc_usable_size(p));
1752 }
1753
1754 __mem_in_probe_ = false;
1755 return p;
1756 }
1757
1758 MEM_NO_INSTRUMENT MEM_INLINE_USED inline void __wrap_free(void *p)
1759 {

Callers

nothing calls this directly

Calls 3

je_realloc_emulateFunction · 0.85
subMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected