- Timestamp:
- Apr 4, 2020 10:46:18 AM (5 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/alloc-ef-r0drv.cpp
r83368 r83546 137 137 RTMEMTYPE_RTMEMREALLOC, 138 138 RTMEMTYPE_RTMEMFREE, 139 RTMEMTYPE_RTMEMFREEZ, 139 140 140 141 RTMEMTYPE_NEW, … … 645 646 * Internal free. 646 647 */ 647 static void rtR0MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL)648 static void rtR0MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, size_t cbUser, void *pvCaller, RT_SRC_POS_DECL) 648 649 { 649 650 NOREF(enmType); RT_SRC_POS_NOREF(); … … 694 695 #endif 695 696 696 #ifdef RTR0MEM_EF_FREE_FILL697 697 /* 698 698 * Fill the user part of the block. 699 699 */ 700 memset(pv, RTR0MEM_EF_FREE_FILL, pBlock->cbUnaligned); 700 AssertMsg(enmType != RTMEMTYPE_RTMEMFREEZ || cbUser == pBlock->cbUnaligned, 701 ("cbUser=%#zx cbUnaligned=%#zx\n", cbUser, pBlock->cbUnaligned)); 702 if (enmType == RTMEMTYPE_RTMEMFREEZ) 703 RT_BZERO(pv, pBlock->cbUnaligned); 704 #ifdef RTR0MEM_EF_FREE_FILL 705 else 706 memset(pv, RTR0MEM_EF_FREE_FILL, pBlock->cbUnaligned); 701 707 #endif 702 708 … … 748 754 if (!cbNew) 749 755 { 750 rtR0MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, RT_SRC_POS_ARGS);756 rtR0MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, 0, pvCaller, RT_SRC_POS_ARGS); 751 757 return NULL; 752 758 } … … 762 768 { 763 769 memcpy(pvRet, pvOld, RT_MIN(cbNew, pBlock->cbUnaligned)); 764 rtR0MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, RT_SRC_POS_ARGS);770 rtR0MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, 0, pvCaller, RT_SRC_POS_ARGS); 765 771 } 766 772 return pvRet; … … 788 794 { 789 795 if (pv) 790 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS_ARGS); 796 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), RT_SRC_POS_ARGS); 797 } 798 799 800 RTDECL(void) RTMemEfTmpFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_DEF 801 { 802 if (pv) 803 rtR0MemFree("FreeZ", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), RT_SRC_POS_ARGS); 791 804 } 792 805 … … 843 856 { 844 857 if (pv) 845 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS_ARGS); 858 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), RT_SRC_POS_ARGS); 859 } 860 861 862 RTDECL(void) RTMemEfFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_DEF 863 { 864 if (pv) 865 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), RT_SRC_POS_ARGS); 846 866 } 847 867 … … 893 913 { 894 914 if (pv) 895 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL); 915 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 916 } 917 918 919 RTDECL(void) RTMemEfTmpFreeZNP(void *pv, size_t cb) RT_NO_THROW_DEF 920 { 921 if (pv) 922 rtR0MemFree("FreeZ", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), NULL, 0, NULL); 896 923 } 897 924 … … 949 976 { 950 977 if (pv) 951 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL); 978 rtR0MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 979 } 980 981 982 RTDECL(void) RTMemEfFreeZNP(void *pv, size_t cb) RT_NO_THROW_DEF 983 { 984 if (pv) 985 rtR0MemFree("FreeZ", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), NULL, 0, NULL); 952 986 } 953 987 -
trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp
r82968 r83546 112 112 113 113 114 RTDECL(void) RTMemTmpFreeZ(void *pv, size_t cb) RT_NO_THROW_DEF 115 { 116 return RTMemFreeZ(pv, cb); 117 } 118 RT_EXPORT_SYMBOL(RTMemTmpFreeZ); 119 120 114 121 115 122 … … 274 281 } 275 282 RT_EXPORT_SYMBOL(RTMemFree); 283 284 285 RTDECL(void) RTMemFreeZ(void *pv, size_t cb) RT_NO_THROW_DEF 286 { 287 PRTMEMHDR pHdr; 288 RT_ASSERT_INTS_ON(); 289 290 if (!pv) 291 return; 292 pHdr = (PRTMEMHDR)pv - 1; 293 if (pHdr->u32Magic == RTMEMHDR_MAGIC) 294 { 295 Assert(!(pHdr->fFlags & RTMEMHDR_FLAG_ALLOC_EX)); 296 Assert(!(pHdr->fFlags & RTMEMHDR_FLAG_EXEC)); 297 #ifdef RTR0MEM_STRICT 298 AssertReleaseMsg(!memcmp((uint8_t *)(pHdr + 1) + pHdr->cbReq, &g_abFence[0], RTR0MEM_FENCE_EXTRA), 299 ("pHdr=%p pv=%p cbReq=%u cb=%u fFlags=%#x\n" 300 "fence: %.*Rhxs\n" 301 "expected: %.*Rhxs\n", 302 pHdr, pv, pHdr->cbReq, pHdr->cb, pHdr->fFlags, 303 RTR0MEM_FENCE_EXTRA, (uint8_t *)(pHdr + 1) + pHdr->cbReq, 304 RTR0MEM_FENCE_EXTRA, &g_abFence[0])); 305 #endif 306 AssertMsgStmt(cb == pHdr->cbReq, ("cb=%#zx cbReq=%#x\n", cb, pHdr->cbReq), cb = pHdr->cbReq); 307 RT_BZERO(pv, cb); 308 rtR0MemFree(pHdr); 309 } 310 else 311 AssertMsgFailed(("pHdr->u32Magic=%RX32 pv=%p\n", pHdr->u32Magic, pv)); 312 } 313 RT_EXPORT_SYMBOL(RTMemFreeZ); 276 314 277 315 -
trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp
r82968 r83546 91 91 void RT_EF_CDECL operator delete(void *pv) RT_EF_NOTHROW 92 92 { 93 rtR3MemFree("delete", RTMEMTYPE_DELETE, pv, ASMReturnAddress(), NULL, 0, NULL);93 rtR3MemFree("delete", RTMEMTYPE_DELETE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 94 94 } 95 95 … … 100 100 NOREF(cb); 101 101 AssertMsgFailed(("cb ignored!\n")); 102 rtR3MemFree("delete", RTMEMTYPE_DELETE, pv, ASMReturnAddress(), NULL, 0, NULL);102 rtR3MemFree("delete", RTMEMTYPE_DELETE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 103 103 } 104 104 #endif … … 107 107 void RT_EF_CDECL operator delete(void * pv, const std::nothrow_t &) RT_EF_NOTHROW 108 108 { 109 rtR3MemFree("delete nothrow", RTMEMTYPE_DELETE, pv, ASMReturnAddress(), NULL, 0, NULL);109 rtR3MemFree("delete nothrow", RTMEMTYPE_DELETE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 110 110 } 111 111 … … 137 137 void RT_EF_CDECL operator delete[](void * pv) RT_EF_NOTHROW 138 138 { 139 rtR3MemFree("delete[]", RTMEMTYPE_DELETE_ARRAY, pv, ASMReturnAddress(), NULL, 0, NULL);139 rtR3MemFree("delete[]", RTMEMTYPE_DELETE_ARRAY, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 140 140 } 141 141 … … 146 146 NOREF(cb); 147 147 AssertMsgFailed(("cb ignored!\n")); 148 rtR3MemFree("delete[]", RTMEMTYPE_DELETE_ARRAY, pv, ASMReturnAddress(), NULL, 0, NULL);148 rtR3MemFree("delete[]", RTMEMTYPE_DELETE_ARRAY, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 149 149 } 150 150 #endif … … 153 153 void RT_EF_CDECL operator delete[](void *pv, const std::nothrow_t &) RT_EF_NOTHROW 154 154 { 155 rtR3MemFree("delete[] nothrow", RTMEMTYPE_DELETE_ARRAY, pv, ASMReturnAddress(), NULL, 0, NULL);155 rtR3MemFree("delete[] nothrow", RTMEMTYPE_DELETE_ARRAY, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 156 156 } 157 157 -
trunk/src/VBox/Runtime/r3/alloc-ef.cpp
r83368 r83546 368 368 PRTMEMBLOCK pBlock = rtmemBlockGet(pv); 369 369 if (pBlock) 370 rtR3MemFree("r-free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS);370 rtR3MemFree("r-free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), RT_SRC_POS); 371 371 else 372 372 g_pfnOrgFree(pv); … … 649 649 * Internal free. 650 650 */ 651 RTDECL(void) rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL)651 RTDECL(void) rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, size_t cbUser, void *pvCaller, RT_SRC_POS_DECL) 652 652 { 653 653 NOREF(enmType); RT_SRC_POS_NOREF(); … … 699 699 # endif 700 700 701 # ifdef RTALLOC_EFENCE_FREE_FILL702 701 /* 703 702 * Fill the user part of the block. 704 703 */ 705 memset(pv, RTALLOC_EFENCE_FREE_FILL, pBlock->cbUnaligned); 704 AssertMsg(enmType != RTMEMTYPE_RTMEMFREEZ || cbUser == pBlock->cbUnaligned, 705 ("cbUser=%#zx cbUnaligned=%#zx\n", cbUser, pBlock->cbUnaligned)); 706 if (enmType == RTMEMTYPE_RTMEMFREEZ) 707 RT_BZERO(pv, pBlock->cbUnaligned); 708 #ifdef RTALLOC_EFENCE_FREE_FILL 709 else 710 memset(pv, RTALLOC_EFENCE_FREE_FILL, pBlock->cbUnaligned); 706 711 # endif 707 712 … … 790 795 if (!cbNew) 791 796 { 792 rtR3MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, RT_SRC_POS_ARGS);797 rtR3MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, 0, pvCaller, RT_SRC_POS_ARGS); 793 798 return NULL; 794 799 } … … 806 811 { 807 812 memcpy(pvRet, pvOld, RT_MIN(cbNew, pBlock->cbUnaligned)); 808 rtR3MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, RT_SRC_POS_ARGS);813 rtR3MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, 0, pvCaller, RT_SRC_POS_ARGS); 809 814 } 810 815 return pvRet; … … 840 845 { 841 846 if (pv) 842 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS_ARGS); 847 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), RT_SRC_POS_ARGS); 848 } 849 850 851 RTDECL(void) RTMemEfTmpFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_DEF 852 { 853 if (pv) 854 rtR3MemFree("FreeZ", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), RT_SRC_POS_ARGS); 843 855 } 844 856 … … 896 908 { 897 909 if (pv) 898 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS_ARGS); 910 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), RT_SRC_POS_ARGS); 911 } 912 913 914 RTDECL(void) RTMemEfFreeZ(void *pv, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW_DEF 915 { 916 if (pv) 917 rtR3MemFree("FreeZ", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), RT_SRC_POS_ARGS); 899 918 } 900 919 … … 946 965 { 947 966 if (pv) 948 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL); 967 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 968 } 969 970 971 RTDECL(void) RTMemEfTmpFreeZNP(void *pv, size_t cb) RT_NO_THROW_DEF 972 { 973 if (pv) 974 rtR3MemFree("FreeZ", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), NULL, 0, NULL); 949 975 } 950 976 … … 1002 1028 { 1003 1029 if (pv) 1004 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL); 1030 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 1031 } 1032 1033 1034 RTDECL(void) RTMemEfFreeZNP(void *pv, size_t cb) RT_NO_THROW_DEF 1035 { 1036 if (pv) 1037 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), NULL, 0, NULL); 1005 1038 } 1006 1039 -
trunk/src/VBox/Runtime/r3/alloc-ef.h
r82968 r83546 157 157 RTMEMTYPE_RTMEMREALLOC, 158 158 RTMEMTYPE_RTMEMFREE, 159 RTMEMTYPE_RTMEMFREEZ, 159 160 160 161 RTMEMTYPE_NEW, … … 201 202 RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, 202 203 const char *pszTag, void *pvCaller, RT_SRC_POS_DECL); 203 RTDECL(void) rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL);204 RTDECL(void) rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, size_t cbUser, void *pvCaller, RT_SRC_POS_DECL); 204 205 RT_C_DECLS_END 205 206 -
trunk/src/VBox/Runtime/r3/alloc.cpp
r82968 r83546 67 67 #undef RTMemTmpAllocZTag 68 68 #undef RTMemTmpFree 69 #undef RTMemTmpFreeZ 69 70 #undef RTMemAlloc 70 71 #undef RTMemAllocTag … … 78 79 #undef RTMemReallocTag 79 80 #undef RTMemFree 81 #undef RTMemFreeZ 80 82 #undef RTMemDup 81 83 #undef RTMemDupTag … … 139 141 140 142 143 RTDECL(void) RTMemTmpFreeZ(void *pv, size_t cb) RT_NO_THROW_DEF 144 { 145 RTMemFreeZ(pv, cb); 146 } 147 148 141 149 RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF 142 150 { … … 255 263 if (pv) 256 264 #ifdef RTALLOC_USE_EFENCE 257 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL);265 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, 0, ASMReturnAddress(), NULL, 0, NULL); 258 266 #else 259 267 # ifdef RTMEMALLOC_USE_TRACKER … … 265 273 266 274 275 RTDECL(void) RTMemFreeZ(void *pv, size_t cb) RT_NO_THROW_DEF 276 { 277 if (pv) 278 { 279 #ifdef RTALLOC_USE_EFENCE 280 rtR3MemFree("Free", RTMEMTYPE_RTMEMFREEZ, pv, cb, ASMReturnAddress(), NULL, 0, NULL); 281 #else 282 # ifdef RTMEMALLOC_USE_TRACKER 283 pv = RTMemTrackerHdrFree(pv, cb, NULL, ASMReturnAddress(), RTMEMTRACKERMETHOD_FREE); 284 # endif 285 RT_BZERO(pv, cb); 286 free(pv); 287 #endif 288 } 289 } 290 291 267 292 268 293 DECLHIDDEN(void *) rtMemBaseAlloc(size_t cb)
Note:
See TracChangeset
for help on using the changeset viewer.