Changeset 31157 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Jul 28, 2010 3:15:35 AM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp
r28800 r31157 58 58 void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb) throw(std::bad_alloc) 59 59 { 60 void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);60 void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL); 61 61 if (!pv) 62 62 throw std::bad_alloc(); … … 67 67 void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb, const std::nothrow_t &) throw() 68 68 { 69 void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);69 void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL); 70 70 return pv; 71 71 } … … 94 94 void *RT_EF_CDECL operator new[](RT_EF_SIZE_T cb) throw(std::bad_alloc) 95 95 { 96 void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);96 void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL); 97 97 if (!pv) 98 98 throw std::bad_alloc(); … … 103 103 void * RT_EF_CDECL operator new[](RT_EF_SIZE_T cb, const std::nothrow_t &) throw() 104 104 { 105 void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);105 void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, NULL, ASMReturnAddress(), NULL, 0, NULL); 106 106 return pv; 107 107 } -
trunk/src/VBox/Runtime/r3/alloc-ef.cpp
r28800 r31157 127 127 */ 128 128 DECLINLINE(PRTMEMBLOCK) rtmemBlockCreate(RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned, 129 void *pvCaller, RT_SRC_POS_DECL)129 const char *pszTag, void *pvCaller, RT_SRC_POS_DECL) 130 130 { 131 131 PRTMEMBLOCK pBlock = (PRTMEMBLOCK)malloc(sizeof(*pBlock)); … … 135 135 pBlock->cbUnaligned = cbUnaligned; 136 136 pBlock->cbAligned = cbAligned; 137 pBlock->pszTag = pszTag; 137 138 pBlock->pvCaller = pvCaller; 138 139 pBlock->iLine = iLine; … … 273 274 */ 274 275 RTDECL(void *) rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned, 275 void *pvCaller, RT_SRC_POS_DECL)276 const char *pszTag, void *pvCaller, RT_SRC_POS_DECL) 276 277 { 277 278 /* … … 305 306 * Allocate the trace block. 306 307 */ 307 PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, p vCaller, RT_SRC_POS_ARGS);308 PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, pszTag, pvCaller, RT_SRC_POS_ARGS); 308 309 if (!pBlock) 309 310 { … … 503 504 * Internal realloc. 504 505 */ 505 RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL) 506 RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, 507 const char *pszTag, void *pvCaller, RT_SRC_POS_DECL) 506 508 { 507 509 /* … … 509 511 */ 510 512 if (!pvOld) 511 return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, p vCaller, RT_SRC_POS_ARGS);513 return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pszTag, pvCaller, RT_SRC_POS_ARGS); 512 514 if (!cbNew) 513 515 { … … 524 526 if (pBlock) 525 527 { 526 void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, p vCaller, RT_SRC_POS_ARGS);528 void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pszTag, pvCaller, RT_SRC_POS_ARGS); 527 529 if (pvRet) 528 530 { … … 547 549 548 550 549 RTDECL(void *) RTMemEfTmpAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW550 { 551 return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);552 } 553 554 555 RTDECL(void *) RTMemEfTmpAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW556 { 557 return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);551 RTDECL(void *) RTMemEfTmpAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 552 { 553 return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 554 } 555 556 557 RTDECL(void *) RTMemEfTmpAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 558 { 559 return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 558 560 } 559 561 … … 566 568 567 569 568 RTDECL(void *) RTMemEfAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW569 { 570 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);571 } 572 573 574 RTDECL(void *) RTMemEfAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW575 { 576 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);577 } 578 579 580 RTDECL(void *) RTMemEfAllocVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW570 RTDECL(void *) RTMemEfAlloc(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 571 { 572 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 573 } 574 575 576 RTDECL(void *) RTMemEfAllocZ(size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 577 { 578 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 579 } 580 581 582 RTDECL(void *) RTMemEfAllocVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 581 583 { 582 584 size_t cbAligned; … … 585 587 else 586 588 cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *)); 587 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);588 } 589 590 591 RTDECL(void *) RTMemEfAllocZVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW589 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 590 } 591 592 593 RTDECL(void *) RTMemEfAllocZVar(size_t cbUnaligned, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 592 594 { 593 595 size_t cbAligned; … … 596 598 else 597 599 cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *)); 598 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);599 } 600 601 602 RTDECL(void *) RTMemEfRealloc(void *pvOld, size_t cbNew, RT_SRC_POS_DECL) RT_NO_THROW603 { 604 return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), RT_SRC_POS_ARGS);600 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 601 } 602 603 604 RTDECL(void *) RTMemEfRealloc(void *pvOld, size_t cbNew, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 605 { 606 return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), RT_SRC_POS_ARGS); 605 607 } 606 608 … … 613 615 614 616 615 RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW616 { 617 void *pvDst = RTMemEfAlloc(cb, RT_SRC_POS_ARGS);617 RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 618 { 619 void *pvDst = RTMemEfAlloc(cb, pszTag, RT_SRC_POS_ARGS); 618 620 if (pvDst) 619 621 memcpy(pvDst, pvSrc, cb); … … 622 624 623 625 624 RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, RT_SRC_POS_DECL) RT_NO_THROW625 { 626 void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, RT_SRC_POS_ARGS);626 RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag, RT_SRC_POS_DECL) RT_NO_THROW 627 { 628 void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, pszTag, RT_SRC_POS_ARGS); 627 629 if (pvDst) 628 630 { … … 644 646 645 647 646 RTDECL(void *) RTMemEfTmpAllocNP(size_t cb ) RT_NO_THROW647 { 648 return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);649 } 650 651 652 RTDECL(void *) RTMemEfTmpAllocZNP(size_t cb ) RT_NO_THROW653 { 654 return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);648 RTDECL(void *) RTMemEfTmpAllocNP(size_t cb, const char *pszTag) RT_NO_THROW 649 { 650 return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL); 651 } 652 653 654 RTDECL(void *) RTMemEfTmpAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW 655 { 656 return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL); 655 657 } 656 658 … … 663 665 664 666 665 RTDECL(void *) RTMemEfAllocNP(size_t cb ) RT_NO_THROW666 { 667 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);668 } 669 670 671 RTDECL(void *) RTMemEfAllocZNP(size_t cb ) RT_NO_THROW672 { 673 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);674 } 675 676 677 RTDECL(void *) RTMemEfAllocVarNP(size_t cbUnaligned ) RT_NO_THROW667 RTDECL(void *) RTMemEfAllocNP(size_t cb, const char *pszTag) RT_NO_THROW 668 { 669 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL); 670 } 671 672 673 RTDECL(void *) RTMemEfAllocZNP(size_t cb, const char *pszTag) RT_NO_THROW 674 { 675 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL); 676 } 677 678 679 RTDECL(void *) RTMemEfAllocVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW 678 680 { 679 681 size_t cbAligned; … … 682 684 else 683 685 cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *)); 684 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);685 } 686 687 688 RTDECL(void *) RTMemEfAllocZVarNP(size_t cbUnaligned ) RT_NO_THROW686 return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL); 687 } 688 689 690 RTDECL(void *) RTMemEfAllocZVarNP(size_t cbUnaligned, const char *pszTag) RT_NO_THROW 689 691 { 690 692 size_t cbAligned; … … 693 695 else 694 696 cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *)); 695 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);696 } 697 698 699 RTDECL(void *) RTMemEfReallocNP(void *pvOld, size_t cbNew ) RT_NO_THROW700 { 701 return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);697 return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL); 698 } 699 700 701 RTDECL(void *) RTMemEfReallocNP(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW 702 { 703 return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), NULL, 0, NULL); 702 704 } 703 705 … … 710 712 711 713 712 RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb ) RT_NO_THROW713 { 714 void *pvDst = RTMemEfAlloc(cb, NULL, 0, NULL);714 RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb, const char *pszTag) RT_NO_THROW 715 { 716 void *pvDst = RTMemEfAlloc(cb, pszTag, NULL, 0, NULL); 715 717 if (pvDst) 716 718 memcpy(pvDst, pvSrc, cb); … … 719 721 720 722 721 RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra ) RT_NO_THROW722 { 723 void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, NULL, 0, NULL);723 RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra, const char *pszTag) RT_NO_THROW 724 { 725 void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, pszTag, NULL, 0, NULL); 724 726 if (pvDst) 725 727 { -
trunk/src/VBox/Runtime/r3/alloc-ef.h
r28800 r31157 166 166 /** The aligned size of the block. */ 167 167 size_t cbAligned; 168 /** The allocation tag (read-only string). */ 169 const char *pszTag; 168 170 /** The return address of the allocator function. */ 169 171 void *pvCaller; … … 184 186 RT_C_DECLS_BEGIN 185 187 RTDECL(void *) rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned, 186 void *pvCaller, RT_SRC_POS_DECL); 187 RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL); 188 const char *pszTag, void *pvCaller, RT_SRC_POS_DECL); 189 RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, 190 const char *pszTag, void *pvCaller, RT_SRC_POS_DECL); 188 191 RTDECL(void) rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL); 189 192 RT_C_DECLS_END -
trunk/src/VBox/Runtime/r3/alloc.cpp
r28800 r31157 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 48 48 49 49 #undef RTMemTmpAlloc 50 #undef RTMemTmpAllocTag 50 51 #undef RTMemTmpAllocZ 52 #undef RTMemTmpAllocZTag 51 53 #undef RTMemTmpFree 52 54 #undef RTMemAlloc 55 #undef RTMemAllocTag 53 56 #undef RTMemAllocZ 57 #undef RTMemAllocZTag 54 58 #undef RTMemAllocVar 59 #undef RTMemAllocVarTag 55 60 #undef RTMemAllocZVar 61 #undef RTMemAllocZVarTag 56 62 #undef RTMemRealloc 63 #undef RTMemReallocTag 57 64 #undef RTMemFree 58 65 #undef RTMemDup 66 #undef RTMemDupTag 59 67 #undef RTMemDupEx 68 #undef RTMemDupExTag 60 69 61 70 62 /** 63 * Allocates temporary memory. 64 * 65 * Temporary memory blocks are used for not too large memory blocks which 66 * are believed not to stick around for too long. Using this API instead 67 * of RTMemAlloc() not only gives the heap manager room for optimization 68 * but makes the code easier to read. 69 * 70 * @returns Pointer to the allocated memory. 71 * @returns NULL on failure. 72 * @param cb Size in bytes of the memory block to allocate. 73 */ 74 RTDECL(void *) RTMemTmpAlloc(size_t cb) RT_NO_THROW 71 RTDECL(void *) RTMemTmpAllocTag(size_t cb, const char *pszTag) RT_NO_THROW 75 72 { 76 return RTMemAlloc (cb);73 return RTMemAllocTag(cb, pszTag); 77 74 } 78 75 79 76 80 /** 81 * Allocates zero'ed temporary memory. 82 * 83 * Same as RTMemTmpAlloc() but the memory will be zero'ed. 84 * 85 * @returns Pointer to the allocated memory. 86 * @returns NULL on failure. 87 * @param cb Size in bytes of the memory block to allocate. 88 */ 89 RTDECL(void *) RTMemTmpAllocZ(size_t cb) RT_NO_THROW 77 RTDECL(void *) RTMemTmpAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW 90 78 { 91 return RTMemAllocZ (cb);79 return RTMemAllocZTag(cb, pszTag); 92 80 } 93 81 94 82 95 /** 96 * Free temporary memory. 97 * 98 * @param pv Pointer to memory block. 99 */ 100 RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW 83 RTDECL(void) RTMemTmpFree(void *pv) RT_NO_THROW 101 84 { 102 85 RTMemFree(pv); … … 104 87 105 88 106 /** 107 * Allocates memory. 108 * 109 * @returns Pointer to the allocated memory. 110 * @returns NULL on failure. 111 * @param cb Size in bytes of the memory block to allocate. 112 */ 113 RTDECL(void *) RTMemAlloc(size_t cb) RT_NO_THROW 89 RTDECL(void *) RTMemAllocTag(size_t cb, const char *pszTag) RT_NO_THROW 114 90 { 115 91 #ifdef RTALLOC_USE_EFENCE 116 void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);92 void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL); 117 93 118 94 #else /* !RTALLOC_USE_EFENCE */ … … 130 106 131 107 132 /** 133 * Allocates zero'ed memory. 134 * 135 * Instead of memset(pv, 0, sizeof()) use this when you want zero'ed 136 * memory. This keeps the code smaller and the heap can skip the memset 137 * in about 0.42% of the calls :-). 138 * 139 * @returns Pointer to the allocated memory. 140 * @returns NULL on failure. 141 * @param cb Size in bytes of the memory block to allocate. 142 */ 143 RTDECL(void *) RTMemAllocZ(size_t cb) RT_NO_THROW 108 RTDECL(void *) RTMemAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW 144 109 { 145 110 #ifdef RTALLOC_USE_EFENCE 146 void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);111 void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, pszTag, ASMReturnAddress(), NULL, 0, NULL); 147 112 148 113 #else /* !RTALLOC_USE_EFENCE */ … … 161 126 162 127 163 /** 164 * Wrapper around RTMemAlloc for automatically aligning variable sized 165 * allocations so that the various electric fence heaps works correctly. 166 * 167 * @returns See RTMemAlloc. 168 * @param cbUnaligned The unaligned size. 169 */ 170 RTDECL(void *) RTMemAllocVar(size_t cbUnaligned) 128 RTDECL(void *) RTMemAllocVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW 171 129 { 172 130 size_t cbAligned; … … 176 134 cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *)); 177 135 #ifdef RTALLOC_USE_EFENCE 178 void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);136 void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL); 179 137 #else 180 void *pv = RTMemAlloc (cbAligned);138 void *pv = RTMemAllocTag(cbAligned, pszTag); 181 139 #endif 182 140 return pv; … … 184 142 185 143 186 /** 187 * Wrapper around RTMemAllocZ for automatically aligning variable sized 188 * allocations so that the various electric fence heaps works correctly. 189 * 190 * @returns See RTMemAllocZ. 191 * @param cbUnaligned The unaligned size. 192 */ 193 RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned) 144 RTDECL(void *) RTMemAllocZVarTag(size_t cbUnaligned, const char *pszTag) RT_NO_THROW 194 145 { 195 146 size_t cbAligned; … … 199 150 cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *)); 200 151 #ifdef RTALLOC_USE_EFENCE 201 void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);152 void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, pszTag, ASMReturnAddress(), NULL, 0, NULL); 202 153 #else 203 void *pv = RTMemAllocZ (cbAligned);154 void *pv = RTMemAllocZTag(cbAligned, pszTag); 204 155 #endif 205 156 return pv; … … 207 158 208 159 209 /** 210 * Reallocates memory. 211 * 212 * @returns Pointer to the allocated memory. 213 * @returns NULL on failure. 214 * @param pvOld The memory block to reallocate. 215 * @param cbNew The new block size (in bytes). 216 */ 217 RTDECL(void *) RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW 160 RTDECL(void *) RTMemReallocTag(void *pvOld, size_t cbNew, const char *pszTag) RT_NO_THROW 218 161 { 219 162 #ifdef RTALLOC_USE_EFENCE 220 void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);163 void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, pszTag, ASMReturnAddress(), NULL, 0, NULL); 221 164 222 165 #else /* !RTALLOC_USE_EFENCE */ … … 233 176 234 177 235 /** 236 * Free memory related to a virtual machine 237 * 238 * @param pv Pointer to memory block. 239 */ 240 RTDECL(void) RTMemFree(void *pv) RT_NO_THROW 178 RTDECL(void) RTMemFree(void *pv) RT_NO_THROW 241 179 { 242 180 if (pv) -
trunk/src/VBox/Runtime/r3/darwin/alloc-darwin.cpp
r28800 r31157 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 40 40 41 41 42 /** 43 * Allocates memory which may contain code. 44 * 45 * @returns Pointer to the allocated memory. 46 * @returns NULL on failure. 47 * @param cb Size in bytes of the memory block to allocate. 48 */ 49 RTDECL(void *) RTMemExecAlloc(size_t cb) RT_NO_THROW 42 RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW 50 43 { 51 44 /* … … 74 67 75 68 76 /**77 * Free executable/read/write memory allocated by RTMemExecAlloc().78 *79 * @param pv Pointer to memory block.80 */81 69 RTDECL(void) RTMemExecFree(void *pv) RT_NO_THROW 82 70 { … … 86 74 87 75 88 /** 89 * Allocate page aligned memory. 90 * 91 * @returns Pointer to the allocated memory. 92 * @returns NULL if we're out of memory. 93 * @param cb Size of the memory block. Will be rounded up to page size. 94 */ 95 RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW 76 RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW 96 77 { 97 78 return valloc(RT_ALIGN_Z(cb, PAGE_SIZE)); … … 99 80 100 81 101 /** 102 * Allocate zero'ed page aligned memory. 103 * 104 * @returns Pointer to the allocated memory. 105 * @returns NULL if we're out of memory. 106 * @param cb Size of the memory block. Will be rounded up to page size. 107 */ 108 RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW 82 RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW 109 83 { 110 84 cb = RT_ALIGN_Z(cb, PAGE_SIZE); … … 116 90 117 91 118 /**119 * Free a memory block allocated with RTMemPageAlloc() or RTMemPageAllocZ().120 *121 * @param pv Pointer to the block as it was returned by the allocation function.122 * NULL will be ignored.123 */124 92 RTDECL(void) RTMemPageFree(void *pv, size_t cb) RT_NO_THROW 125 93 { … … 129 97 130 98 131 /**132 * Change the page level protection of a memory region.133 *134 * @returns iprt status code.135 * @param pv Start of the region. Will be rounded down to nearest page boundary.136 * @param cb Size of the region. Will be rounded up to the nearest page boundary.137 * @param fProtect The new protection, a combination of the RTMEM_PROT_* defines.138 */139 99 RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW 140 100 { -
trunk/src/VBox/Runtime/r3/posix/utf8-posix.cpp
r30294 r31157 413 413 414 414 415 /** 416 * Allocates tmp buffer, translates pszString from UTF8 to current codepage. 417 * 418 * @returns iprt status code. 419 * @param ppszString Receives pointer of allocated native CP string. 420 * The returned pointer must be freed using RTStrFree(). 421 * @param pszString UTF-8 string to convert. 422 */ 423 RTR3DECL(int) RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString) 415 RTR3DECL(int) RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag) 424 416 { 425 417 Assert(ppszString); … … 434 426 { 435 427 /* zero length string passed. */ 436 *ppszString = (char *)RTMemTmpAllocZ (sizeof(char));428 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag); 437 429 if (*ppszString) 438 430 return VINF_SUCCESS; … … 443 435 444 436 445 /** 446 * Allocates tmp buffer, translates pszString from current codepage to UTF-8. 447 * 448 * @returns iprt status code. 449 * @param ppszString Receives pointer of allocated UTF-8 string. 450 * The returned pointer must be freed using RTStrFree(). 451 * @param pszString Native string to convert. 452 */ 453 RTR3DECL(int) RTStrCurrentCPToUtf8(char **ppszString, const char *pszString) 437 RTR3DECL(int) RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag) 454 438 { 455 439 Assert(ppszString); … … 464 448 { 465 449 /* zero length string passed. */ 466 *ppszString = (char *)RTMemTmpAllocZ (sizeof(char));450 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag); 467 451 if (*ppszString) 468 452 return VINF_SUCCESS; -
trunk/src/VBox/Runtime/r3/win/utf8-win.cpp
r28800 r31157 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 38 38 39 39 40 /** 41 * Allocates tmp buffer, translates pszString from UTF8 to current codepage. 42 * 43 * @returns iprt status code. 44 * @param ppszString Receives pointer of allocated native CP string. 45 * The returned pointer must be freed using RTStrFree(). 46 * @param pszString UTF-8 string to convert. 47 */ 48 RTR3DECL(int) RTStrUtf8ToCurrentCP(char **ppszString, const char *pszString) 40 RTR3DECL(int) RTStrUtf8ToCurrentCPTag(char **ppszString, const char *pszString, const char *pszTag) 49 41 { 50 42 Assert(ppszString); … … 56 48 if (!*pszString) 57 49 { 58 *ppszString = (char *)RTMemTmpAllocZ (sizeof(char));50 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag); 59 51 if (*ppszString) 60 52 return VINF_SUCCESS; … … 81 73 * Alloc space for result buffer. 82 74 */ 83 LPSTR lpString = (LPSTR)RTMemTmpAlloc (cbResult);75 LPSTR lpString = (LPSTR)RTMemTmpAllocTag(cbResult, pszTag); 84 76 if (lpString) 85 77 { … … 115 107 } 116 108 117 /** 118 * Allocates tmp buffer, translates pszString from current codepage to UTF-8. 119 * 120 * @returns iprt status code. 121 * @param ppszString Receives pointer of allocated UTF-8 string. 122 * The returned pointer must be freed using RTStrFree(). 123 * @param pszString Native string to convert. 124 */ 125 RTR3DECL(int) RTStrCurrentCPToUtf8(char **ppszString, const char *pszString) 109 110 RTR3DECL(int) RTStrCurrentCPToUtf8Tag(char **ppszString, const char *pszString, const char *pszTag) 126 111 { 127 112 Assert(ppszString); … … 135 120 { 136 121 /* zero length string passed. */ 137 *ppszString = (char *)RTMemTmpAllocZ (sizeof(char));122 *ppszString = (char *)RTMemTmpAllocZTag(sizeof(char), pszTag); 138 123 if (*ppszString) 139 124 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.