VirtualBox

Changeset 95804 in vbox


Ignore:
Timestamp:
Jul 25, 2022 12:29:26 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152526
Message:

IPRT/alloc-win.cpp: Define USE_VIRTUAL_ALLOC in IPRT_NO_CRT mode; added missing USE_VIRTUAL_ALLOC variants of the exec allocator. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/alloc-win.cpp

    r93115 r95804  
    2929*   Header Files                                                                                                                 *
    3030*********************************************************************************************************************************/
    31 /*#define USE_VIRTUAL_ALLOC*/
     31#ifdef IPRT_NO_CRT
     32# define USE_VIRTUAL_ALLOC
     33#endif
    3234#define LOG_GROUP RTLOGGROUP_MEM
    3335#include <iprt/win/windows.h>
     
    5254     */
    5355    AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
     56#ifdef USE_VIRTUAL_ALLOC
     57    cb = RT_ALIGN_Z(cb, PAGE_SIZE);
     58    void *pv = VirtualAlloc(NULL, cb, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
     59    AssertMsg(pv, ("VirtualAlloc(%zx) failed!!!\n", cb));
     60#else
    5461    cb = RT_ALIGN_Z(cb, 32);
    5562    void *pv = malloc(cb);
     
    6976        }
    7077    }
     78#endif
    7179    return pv;
    7280}
     
    7886
    7987    if (pv)
     88#ifdef USE_VIRTUAL_ALLOC
     89        if (!VirtualFree(pv, 0, MEM_RELEASE))
     90            AssertMsgFailed(("pv=%p lasterr=%d\n", pv, GetLastError()));
     91#else
    8092        free(pv);
     93#endif
    8194}
    8295
Note: See TracChangeset for help on using the changeset viewer.

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