VirtualBox

Changeset 18430 in vbox


Ignore:
Timestamp:
Mar 28, 2009 2:03:31 AM (16 years ago)
Author:
vboxsync
Message:

MMR3HyperAllocOnceNoRel: Another size_t/uint32_t warning from MSC/64. Use this opportunity to optimize the fallback to not wase hyper heap on unnecessary alignment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/MMHyper.cpp

    r18429 r18430  
    892892     * Allocate the pages and map them into HMA space.
    893893     */
    894     cb = RT_ALIGN(cb, PAGE_SIZE);
    895     uint32_t const  cPages = cb >> PAGE_SHIFT;
    896     PSUPPAGE        paPages = (PSUPPAGE)RTMemTmpAlloc(cPages * sizeof(paPages[0]));
     894    uint32_t const  cbAligned = RT_ALIGN_32(cb, PAGE_SIZE);
     895    AssertReturn(cbAligned >= cb, VERR_INVALID_PARAMETER);
     896    uint32_t const  cPages    = cbAligned >> PAGE_SHIFT;
     897    PSUPPAGE        paPages   = (PSUPPAGE)RTMemTmpAlloc(cPages * sizeof(paPages[0]));
    897898    if (!paPages)
    898899        return VERR_NO_TMP_MEMORY;
     
    916917        pvR0 = (uintptr_t)pvPages;
    917918#endif
    918         memset(pvPages, 0, cb);
     919        memset(pvPages, 0, cbAligned);
    919920
    920921        RTGCPTR GCPtr;
     
    929930        {
    930931            *ppv = pvPages;
    931             Log2(("MMR3HyperAllocOnceNoRel: cb=%#x uAlignment=%#x returns VINF_SUCCESS and *ppv=%p\n",
    932                   cb, uAlignment, *ppv));
     932            Log2(("MMR3HyperAllocOnceNoRel: cbAligned=%#x uAlignment=%#x returns VINF_SUCCESS and *ppv=%p\n",
     933                  cbAligned, uAlignment, *ppv));
    933934            MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
    934935            return rc;
    935936        }
    936         AssertMsgFailed(("Failed to allocate %zd bytes! %Rrc\n", cb, rc));
     937        AssertMsgFailed(("Failed to allocate %zd bytes! %Rrc\n", cbAligned, rc));
    937938        SUPR3PageFreeEx(pvPages, cPages);
    938939
     
    943944         */
    944945        /** @todo make a proper fix for this so we will never end up in this kind of situation! */
    945         Log(("MMR3HyperAllocOnceNoRel: MMR3HyperMapHCRam failed with rc=%Rrc, try MMHyperAlloc(,%#d,,) instead\n",  rc, cb));
     946        Log(("MMR3HyperAllocOnceNoRel: MMR3HyperMapHCRam failed with rc=%Rrc, try MMHyperAlloc(,%#x,,) instead\n",  rc, cb));
    946947        int rc2 = MMHyperAlloc(pVM, cb, uAlignment, enmTag, ppv);
    947948        if (RT_SUCCESS(rc2))
     
    953954    }
    954955    else
    955         AssertMsgFailed(("Failed to allocate %zd bytes! %Rrc\n", cb, rc));
     956        AssertMsgFailed(("Failed to allocate %zd bytes! %Rrc\n", cbAligned, rc));
    956957
    957958    if (rc == VERR_NO_MEMORY)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette