Changeset 32707 in vbox for trunk/src/VBox
- Timestamp:
- Sep 23, 2010 10:15:08 AM (14 years ago)
- Location:
- trunk/src/VBox/Runtime/r0drv
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp
r32674 r32707 36 36 #endif 37 37 #include <iprt/assert.h> 38 #ifdef RT_MORE_STRICT 39 # include <iprt/mp.h> 40 #endif 38 41 #include <iprt/param.h> 39 42 #include <iprt/string.h> 40 43 #include <iprt/thread.h> 41 44 #include "r0drv/alloc-r0drv.h" 42 43 #undef RTMemTmpAlloc44 #undef RTMemTmpAllocZ45 #undef RTMemTmpFree46 #undef RTMemAlloc47 #undef RTMemAllocZ48 #undef RTMemAllocVar49 #undef RTMemAllocZVar50 #undef RTMemRealloc51 #undef RTMemFree52 #undef RTMemDup53 #undef RTMemDupEx54 45 55 46 … … 65 56 #else 66 57 # define RTR0MEM_FENCE_EXTRA 0 67 #endif68 69 70 /*******************************************************************************71 * Global Variables *72 *******************************************************************************/73 #ifdef RTR0MEM_STRICT74 /** Fence data. */75 static uint8_t const g_abFence[RTR0MEM_FENCE_EXTRA] =76 {77 0x77, 0x88, 0x66, 0x99, 0x55, 0xaa, 0x44, 0xbb,78 0x33, 0xcc, 0x22, 0xdd, 0x11, 0xee, 0x00, 0xff79 };80 58 #endif 81 59 … … 101 79 #undef RTMemDupEx 102 80 #undef RTMemDupExTag 103 81 #undef rtR0MemAllocEx 82 #undef rtR0MemAllocExTag 83 #undef rtR0MemFreeEx 84 85 86 /******************************************************************************* 87 * Global Variables * 88 *******************************************************************************/ 89 #ifdef RTR0MEM_STRICT 90 /** Fence data. */ 91 static uint8_t const g_abFence[RTR0MEM_FENCE_EXTRA] = 92 { 93 0x77, 0x88, 0x66, 0x99, 0x55, 0xaa, 0x44, 0xbb, 94 0x33, 0xcc, 0x22, 0xdd, 0x11, 0xee, 0x00, 0xff 95 }; 96 #endif 97 98 99 /** 100 * Wrapper around rtR0MemAllocEx. 101 * 102 * @returns Pointer to the allocated memory block header. 103 * @param cb The number of bytes to allocate (sans header). 104 * @param fFlags The allocation flags. 105 */ 106 DECLINLINE(PRTMEMHDR) rtR0MemAlloc(size_t cb, uint32_t fFlags) 107 { 108 PRTMEMHDR pHdr; 109 int rc = rtR0MemAllocEx(cb, fFlags, &pHdr); 110 if (RT_FAILURE(rc)) 111 return NULL; 112 return pHdr; 113 } 104 114 105 115 … … 247 257 if (pHdr->u32Magic == RTMEMHDR_MAGIC) 248 258 { 259 Assert(!(pHdr->fFlags & RTMEMHDR_FLAG_ALLOC_EX)); 249 260 Assert(!(pHdr->fFlags & RTMEMHDR_FLAG_EXEC)); 250 261 #ifdef RTR0MEM_STRICT … … 302 313 if (pHdr->u32Magic == RTMEMHDR_MAGIC) 303 314 { 315 Assert(!(pHdr->fFlags & RTMEMHDR_FLAG_ALLOC_EX)); 304 316 #ifdef RTR0MEM_STRICT 305 317 AssertReleaseMsg(!memcmp((uint8_t *)(pHdr + 1) + pHdr->cbReq, &g_abFence[0], RTR0MEM_FENCE_EXTRA), … … 319 331 320 332 321 /** 322 * Internal IPRT API for allocating special memory. 323 * 324 * @returns Pointer to the allocated memory, NULL on failure. 325 * @param cb The amount of memory to allocate. 326 * @param fFlags Subset of the RTMEMHDR_FLAG_XXX flags. 327 * @param pszTag The tag. 328 */ 329 void *rtR0MemAllocExTag(size_t cb, uint32_t fFlags, const char *pszTag) RT_NO_THROW 330 { 331 /** @todo continue later. */ 332 return NULL; 333 } 334 335 336 /** 337 * For freeing memory allocated by rtR0MemAllocExTag. 338 * 339 * @param pv What to free, NULL is fine. 340 */ 341 void rtR0MemFreeEx(void *pv) RT_NO_THROW 333 334 335 RTDECL(int) RTMemAllocExTag(size_t cb, size_t cbAlignment, uint32_t fFlags, const char *pszTag, void **ppv) RT_NO_THROW 336 { 337 uint32_t fHdrFlags = RTMEMHDR_FLAG_ALLOC_EX; 338 PRTMEMHDR pHdr; 339 int rc; 340 341 RT_ASSERT_PREEMPT_CPUID_VAR(); 342 if (!(fFlags & RTMEMHDR_FLAG_ANY_CTX_ALLOC)) 343 RT_ASSERT_INTS_ON(); 344 345 /* 346 * Fake up some alignment support. 347 */ 348 AssertMsgReturn(cbAlignment <= sizeof(void *), ("%zu (%#x)\n", cbAlignment, cbAlignment), VERR_UNSUPPORTED_ALIGNMENT); 349 if (cb < cbAlignment) 350 cb = cbAlignment; 351 352 /* 353 * Validate and convert flags. 354 */ 355 AssertMsgReturn(!(fFlags & ~RTMEMALLOCEX_FLAGS_VALID_MASK), ("%#x\n", fFlags), NULL); 356 if (fFlags & RTMEMALLOCEX_FLAGS_ZEROED) 357 fHdrFlags |= RTMEMHDR_FLAG_ZEROED; 358 if (fFlags & RTMEMALLOCEX_FLAGS_EXEC) 359 fHdrFlags |= RTMEMHDR_FLAG_EXEC; 360 if (fFlags & RTMEMALLOCEX_FLAGS_ANY_CTX_ALLOC) 361 fHdrFlags |= RTMEMHDR_FLAG_ANY_CTX_ALLOC; 362 if (fFlags & RTMEMALLOCEX_FLAGS_ANY_CTX_FREE) 363 fHdrFlags |= RTMEMHDR_FLAG_ANY_CTX_FREE; 364 365 /* 366 * Do the allocation. 367 */ 368 rc = rtR0MemAllocEx(cb + RTR0MEM_FENCE_EXTRA, fHdrFlags, &pHdr); 369 if (RT_SUCCESS(rc)) 370 { 371 void *pv; 372 373 Assert(pHdr->cbReq == cb + RTR0MEM_FENCE_EXTRA); 374 Assert((pHdr->fFlags & fFlags) == fFlags); 375 376 /* 377 * Calc user pointer, initialize the memory if requested, and if 378 * memory strictness is enable set up the fence. 379 */ 380 pv = pHdr + 1; 381 *ppv = pv; 382 if (fFlags & RTMEMHDR_FLAG_ZEROED) 383 memset(pv, 0, pHdr->cb); 384 385 #ifdef RTR0MEM_STRICT 386 pHdr->cbReq = (uint32_t)cb; 387 memcpy((uint8_t *)pv + cb, &g_abFence[0], RTR0MEM_FENCE_EXTRA); 388 #endif 389 } 390 else if (rc == VERR_NO_MEMORY && (fFlags & RTMEMALLOCEX_FLAGS_EXEC)) 391 rc = VERR_NO_EXEC_MEMORY; 392 393 RT_ASSERT_PREEMPT_CPUID(); 394 return rc; 395 } 396 RT_EXPORT_SYMBOL(RTMemAllocExTag); 397 398 399 RTDECL(void) RTMemFreeEx(void *pv, size_t cb) RT_NO_THROW 342 400 { 343 401 PRTMEMHDR pHdr; … … 345 403 if (!pv) 346 404 return; 405 406 AssertPtr(pv); 347 407 pHdr = (PRTMEMHDR)pv - 1; 348 408 if (pHdr->u32Magic == RTMEMHDR_MAGIC) 349 409 { 410 RT_ASSERT_PREEMPT_CPUID_VAR(); 411 350 412 Assert(pHdr->fFlags & RTMEMHDR_FLAG_ALLOC_EX); 351 if (!(pHdr->fFlags & RTMEMHDR_FLAG_ FREE_ANY_CTX))413 if (!(pHdr->fFlags & RTMEMHDR_FLAG_ANY_CTX_FREE)) 352 414 RT_ASSERT_INTS_ON(); 415 AssertMsg(pHdr->cbReq == cb, ("cbReq=%zu cb=%zu\n", pHdr->cb, cb)); 353 416 354 417 #ifdef RTR0MEM_STRICT … … 362 425 #endif 363 426 rtR0MemFree(pHdr); 427 RT_ASSERT_PREEMPT_CPUID(); 364 428 } 365 429 else 366 430 AssertMsgFailed(("pHdr->u32Magic=%RX32 pv=%p\n", pHdr->u32Magic, pv)); 367 431 } 368 432 RT_EXPORT_SYMBOL(RTMemFreeEx); 433 -
trunk/src/VBox/Runtime/r0drv/alloc-r0drv.h
r32674 r32707 44 44 /** Block flags (RTMEMHDR_FLAG_*). */ 45 45 uint32_t fFlags; 46 /** The actual size of the block . */46 /** The actual size of the block, header not included. */ 47 47 uint32_t cb; 48 /** The request allocation size. */48 /** The requested allocation size. */ 49 49 uint32_t cbReq; 50 50 } RTMEMHDR, *PRTMEMHDR; … … 53 53 /** @name RTMEMHDR::fFlags. 54 54 * @{ */ 55 /** Clear the allocated memory. */ 55 56 #define RTMEMHDR_FLAG_ZEROED RT_BIT(0) 57 /** Executable flag. */ 56 58 #define RTMEMHDR_FLAG_EXEC RT_BIT(1) 57 #define RTMEMHDR_FLAG_ALLOC_ANY_CTX RT_BIT(2) 58 #define RTMEMHDR_FLAG_FREE_ANY_CTX RT_BIT(3) 59 #define RTMEMHDR_FLAG_ANY_CTX (RTMEMHDR_FLAG_ALLOC_ANY_CTX | RTMEMHDR_FLAG_FREE_ANY_CTX) 59 /** Use allocation method suitable for any context. */ 60 #define RTMEMHDR_FLAG_ANY_CTX_ALLOC RT_BIT(2) 61 /** Use allocation method which allow for freeing in any context. */ 62 #define RTMEMHDR_FLAG_ANY_CTX_FREE RT_BIT(3) 63 /** Both alloc and free in any context (or we're just darn lazy). */ 64 #define RTMEMHDR_FLAG_ANY_CTX (RTMEMHDR_FLAG_ANY_CTX_ALLOC | RTMEMHDR_FLAG_ANY_CTX_FREE) 65 /** Indicate that it was allocated by rtR0MemAllocExTag. */ 60 66 #define RTMEMHDR_FLAG_ALLOC_EX RT_BIT(4) 61 67 #ifdef RT_OS_LINUX 68 /** Linux: Allocated from the special heap for executable memory. */ 62 69 # define RTMEMHDR_FLAG_EXEC_HEAP RT_BIT(30) 70 /** Linux: Allocated by kmalloc() instead of vmalloc(). */ 63 71 # define RTMEMHDR_FLAG_KMALLOC RT_BIT(31) 64 72 #endif … … 66 74 67 75 68 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags); 76 /** 77 * Heap allocation back end for ring-0. 78 * 79 * @returns IPRT status code. VERR_NO_MEMORY suffices for RTMEMHDR_FLAG_EXEC, 80 * the caller will change it to VERR_NO_EXEC_MEMORY when appropriate. 81 * 82 * @param cb The amount of memory requested by the user. This does 83 * not include the header. 84 * @param fFlags The allocation flags and more. These should be 85 * assigned to RTMEMHDR::fFlags together with any flags 86 * the backend might be using. 87 * @param ppHdr Where to return the memory header on success. 88 */ 89 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr); 90 91 /** 92 * Free memory allocated by rtR0MemAllocEx. 93 * @param pHdr The memory block to free. (Never NULL.) 94 */ 69 95 void rtR0MemFree(PRTMEMHDR pHdr); 70 #define rtR0MemAllocEx(cb, fFlags) rtR0MemAllocExTag((cb), (fFlags), RTMEM_TAG)71 void *rtR0MemAllocExTag(size_t cb, uint32_t fFlags, const char *pszTag) RT_NO_THROW;72 void rtR0MemFreeEx(void *pv) RT_NO_THROW;73 96 74 97 RT_C_DECLS_END -
trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp
r32674 r32707 41 41 * OS specific allocation function. 42 42 */ 43 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)43 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr) 44 44 { 45 AssertReturn(!(fFlags & RTMEMHDR_FLAG_ANY_CTX), NULL); 45 if (RT_UNLIKELY(fFlags & RTMEMHDR_FLAG_ANY_CTX)) 46 return VERR_NOT_SUPPORTED; 46 47 47 PRTMEMHDR pHdr = (PRTMEMHDR)IOMalloc(cb + sizeof(*pHdr)) ;48 if ( pHdr)48 PRTMEMHDR pHdr = (PRTMEMHDR)IOMalloc(cb + sizeof(*pHdr)) 49 if (RT_UNLIKELY(!pHdr)) 49 50 { 50 pHdr->u32Magic = RTMEMHDR_MAGIC; 51 pHdr->fFlags = fFlags; 52 pHdr->cb = cb; 53 pHdr->cbReq = cb; 51 printf("rtR0MemAllocEx(%#zx, %#x) failed\n", cb + sizeof(*pHdr), fFlags); 52 return VERR_NO_MEMORY; 54 53 } 55 else 56 printf("rmMemAlloc(%#zx, %#x) failed\n", cb + sizeof(*pHdr), fFlags); 57 return pHdr; 54 55 pHdr->u32Magic = RTMEMHDR_MAGIC; 56 pHdr->fFlags = fFlags; 57 pHdr->cb = cb; 58 pHdr->cbReq = cb; 59 *ppHdr = pHdr;; 60 return VINF_SUCCESS; 58 61 } 59 62 -
trunk/src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
r32674 r32707 50 50 51 51 52 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)52 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr) 53 53 { 54 54 size_t cbAllocated = cb; 55 55 PRTMEMHDR pHdr = NULL; 56 56 57 #ifdef RT_ARCH_AMD64 57 58 /* 58 59 * Things are a bit more complicated on AMD64 for executable memory 59 60 * because we need to be in the ~2GB..~0 range for code. 60 61 */ 61 #ifdef RT_ARCH_AMD6462 62 if (fFlags & RTMEMHDR_FLAG_EXEC) 63 63 { 64 AssertReturn(!(fFlags & RTMEMHDR_FLAG_ANY_CTX), NULL); 64 if (fFlags & RTMEMHDR_FLAG_ANY_CTX) 65 return VERR_NOT_SUPPORTED; 65 66 66 67 # ifdef USE_KMEM_ALLOC_PROT … … 74 75 pVmObject = vm_object_allocate(OBJT_DEFAULT, cbAllocated >> PAGE_SHIFT); 75 76 if (!pVmObject) 76 return NULL;77 return VERR_NO_EXEC_MEMORY; 77 78 78 79 /* Addr contains a start address vm_map_find will start searching for suitable space at. */ … … 106 107 } 107 108 108 if (pHdr) 109 { 110 pHdr->u32Magic = RTMEMHDR_MAGIC; 111 pHdr->fFlags = fFlags; 112 pHdr->cb = cbAllocated; 113 pHdr->cbReq = cb; 114 return pHdr; 115 } 116 return NULL; 109 if (RT_UNLIKELY(!pHdr)) 110 return VERR_NO_MEMORY; 111 112 pHdr->u32Magic = RTMEMHDR_MAGIC; 113 pHdr->fFlags = fFlags; 114 pHdr->cb = cbAllocated; 115 pHdr->cbReq = cb; 116 117 *ppHdr = pHdr; 118 return VINF_SUCCESS; 117 119 } 118 120 -
trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
r32674 r32707 111 111 * OS specific allocation function. 112 112 */ 113 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)113 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr) 114 114 { 115 115 PRTMEMHDR pHdr; … … 120 120 if (fFlags & RTMEMHDR_FLAG_EXEC) 121 121 { 122 AssertReturn(!(fFlags & RTMEMHDR_FLAG_ANY_CTX), NULL); 122 if (fFlags & RTMEMHDR_FLAG_ANY_CTX) 123 return VERR_NOT_SUPPORTED; 123 124 124 125 #if defined(RT_ARCH_AMD64) … … 149 150 { 150 151 fFlags |= RTMEMHDR_FLAG_KMALLOC; 151 pHdr = kmalloc(cb + sizeof(*pHdr), GFP_KERNEL); 152 pHdr = kmalloc(cb + sizeof(*pHdr), 153 (fFlags & RTMEMHDR_FLAG_ANY_CTX_ALLOC) ? GFP_ATOMIC : GFP_KERNEL); 152 154 } 153 155 else 154 156 pHdr = vmalloc(cb + sizeof(*pHdr)); 155 157 } 158 if (RT_UNLIKELY(!pHdr)) 159 return VERR_NO_MEMORY; 156 160 157 161 /* 158 162 * Initialize. 159 163 */ 160 if (pHdr) 161 { 162 pHdr->u32Magic = RTMEMHDR_MAGIC; 163 pHdr->fFlags = fFlags; 164 pHdr->cb = cb; 165 pHdr->cbReq = cb; 166 } 167 return pHdr; 164 pHdr->u32Magic = RTMEMHDR_MAGIC; 165 pHdr->fFlags = fFlags; 166 pHdr->cb = cb; 167 pHdr->cbReq = cb; 168 169 *ppHdr = pHdr; 170 return VINF_SUCCESS; 168 171 } 169 172 -
trunk/src/VBox/Runtime/r0drv/linux/timer-r0drv-linux.c
r32670 r32707 434 434 */ 435 435 ASMAtomicWriteU32(&pTimer->u32Magic, ~RTTIMER_MAGIC); 436 #if 0 /*fixme*/ 437 rtR0MemFreeNoCtxCheck(pTimer); 438 #else 439 RTMemFree(pTimer); 440 #endif 436 RTMemFreeEx(pTimer, RT_OFFSETOF(RTTIMER, aSubTimers[pTimer->cCpus])); 441 437 if (hSpinlock != NIL_RTSPINLOCK) 442 438 RTSpinlockDestroy(hSpinlock); … … 1393 1389 RTCPUID iCpu; 1394 1390 unsigned cCpus; 1391 int rc; 1395 1392 1396 1393 *ppTimer = NULL; … … 1419 1416 #endif 1420 1417 1421 pTimer = (PRTTIMER)RTMemAllocZ(RT_OFFSETOF(RTTIMER, aSubTimers[cCpus])); 1422 if (!pTimer) 1423 return VERR_NO_MEMORY; 1418 rc = RTMemAllocEx(RT_OFFSETOF(RTTIMER, aSubTimers[cCpus]), 0, 1419 RTMEMALLOCEX_FLAGS_ZEROED | RTMEMALLOCEX_FLAGS_ANY_CTX_FREE, (void **)&pTimer); 1420 if (RT_FAILURE(rc)) 1421 return rc; 1424 1422 1425 1423 /* -
trunk/src/VBox/Runtime/r0drv/nt/alloc-r0drv-nt.cpp
r32674 r32707 39 39 * OS specific allocation function. 40 40 */ 41 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)41 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr) 42 42 { 43 AssertReturn(!(fFlags & RTMEMHDR_FLAG_ANY_CTX), NULL); 43 if (fFlags & RTMEMHDR_FLAG_ANY_CTX) 44 return VERR_NOT_SUPPORTED; 44 45 45 46 PRTMEMHDR pHdr = (PRTMEMHDR)ExAllocatePoolWithTag(NonPagedPool, cb + sizeof(*pHdr), IPRT_NT_POOL_TAG); 46 if (pHdr) 47 { 48 pHdr->u32Magic = RTMEMHDR_MAGIC; 49 pHdr->fFlags = fFlags; 50 pHdr->cb = (uint32_t)cb; Assert(pHdr->cb == cb); 51 pHdr->cbReq = (uint32_t)cb; 52 } 53 return pHdr; 47 if (RT_UNLIKELY(!pHdr)) 48 return VERR_NO_MEMORY; 49 50 pHdr->u32Magic = RTMEMHDR_MAGIC; 51 pHdr->fFlags = fFlags; 52 pHdr->cb = (uint32_t)cb; Assert(pHdr->cb == cb); 53 pHdr->cbReq = (uint32_t)cb; 54 *ppHdr = pHdr; 55 return VINF_SUCCESS; 54 56 } 55 57 -
trunk/src/VBox/Runtime/r0drv/os2/alloc-r0drv-os2.cpp
r32674 r32707 41 41 42 42 43 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)43 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr) 44 44 { 45 AssertReturn(!(fFlags & RTMEMHDR_FLAG_ANY_CTX), NULL); 45 if (fFlags & RTMEMHDR_FLAG_ANY_CTX) 46 return VERR_NOT_SUPPORTED; 46 47 47 48 void *pv = NULL; 48 49 APIRET rc = KernVMAlloc(cb + sizeof(RTMEMHDR), VMDHA_FIXED, &pv, (void **)-1, NULL); 49 if ( !rc)50 {51 PRTMEMHDR pHdr = (PRTMEMHDR)pv; 52 pHdr->u32Magic = RTMEMHDR_MAGIC;53 pHdr->fFlags = fFlags;54 pHdr->cb = cb;55 pHdr->cbReq= cb;56 return pHdr;57 }58 return NULL;50 if (RT_UNLIKELY(rc != NO_ERROR)) 51 return RTErrConvertFromOS2(rc); 52 53 PRTMEMHDR pHdr = (PRTMEMHDR)pv; 54 pHdr->u32Magic = RTMEMHDR_MAGIC; 55 pHdr->fFlags = fFlags; 56 pHdr->cb = cb; 57 pHdr->cbReq = cb; 58 *ppHdr = pHdr; 59 return VINF_SUCCESS; 59 60 } 60 61 -
trunk/src/VBox/Runtime/r0drv/solaris/vbi/alloc-r0drv-solaris.c
r32674 r32707 44 44 * OS specific allocation function. 45 45 */ 46 PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)46 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr) 47 47 { 48 48 size_t cbAllocated = cb; … … 59 59 #endif 60 60 { 61 unsigned fKmFlags = fFlags & RTMEMHDR_FLAG_A LLOC_ANY_CTX? KM_NOSLEEP : KM_SLEEP;61 unsigned fKmFlags = fFlags & RTMEMHDR_FLAG_ANY_CTX_ALLOC ? KM_NOSLEEP : KM_SLEEP; 62 62 if (fFlags & RTMEMHDR_FLAG_ZEROED) 63 63 pHdr = (PRTMEMHDR)kmem_zalloc(cb + sizeof(*pHdr), fKmFlags); … … 65 65 pHdr = (PRTMEMHDR)kmem_alloc(cb + sizeof(*pHdr), fKmFlags); 66 66 } 67 if ( pHdr)67 if (RT_UNLIKELY(!pHdr)) 68 68 { 69 pHdr->u32Magic = RTMEMHDR_MAGIC; 70 pHdr->fFlags = fFlags; 71 pHdr->cb = cbAllocated; 72 pHdr->cbReq = cb; 69 LogRel(("rtMemAllocEx(%u, %#x) failed\n", (unsigned)cb + sizeof(*pHdr), fFlags)); 70 return VERR_NO_MEMORY; 73 71 } 74 else 75 LogRel(("rtMemAlloc(%u, %#x) failed\n", (unsigned)cb + sizeof(*pHdr), fFlags)); 76 return pHdr; 72 73 pHdr->u32Magic = RTMEMHDR_MAGIC; 74 pHdr->fFlags = fFlags; 75 pHdr->cb = cbAllocated; 76 pHdr->cbReq = cb; 77 78 *ppHdr = pHdr; 79 return VINF_SUCCESS; 77 80 } 78 81
Note:
See TracChangeset
for help on using the changeset viewer.