Index: trunk/src/VBox/Runtime/common/alloc/alloc.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/alloc/alloc.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/common/alloc/alloc.cpp	(revision 28298)
@@ -39,47 +39,7 @@
 #include <iprt/string.h>
 
-#ifdef RTMEM_WRAP_TO_EF_APIS
-# undef RTMemAllocVar
-# undef RTMemAllocZVar
-# undef RTMemDup
-# undef RTMemDupEx
-#endif
+#undef RTMemDup
+#undef RTMemDupEx
 
-
-
-/**
- * Wrapper around RTMemAlloc for automatically aligning variable sized
- * allocations so that the various electric fence heaps works correctly.
- *
- * @returns See RTMemAlloc.
- * @param   cbUnaligned         The unaligned size.
- */
-RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
-{
-    size_t cbAligned;
-    if (cbUnaligned >= 16)
-        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
-    else
-        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return RTMemAlloc(cbAligned);
-}
-
-
-/**
- * Wrapper around RTMemAllocZ for automatically aligning variable sized
- * allocations so that the various electric fence heaps works correctly.
- *
- * @returns See RTMemAllocZ.
- * @param   cbUnaligned         The unaligned size.
- */
-RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
-{
-    size_t cbAligned;
-    if (cbUnaligned >= 16)
-        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
-    else
-        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return RTMemAllocZ(cbAligned);
-}
 
 
Index: trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/alloc-r0drv.cpp	(revision 28298)
@@ -43,4 +43,16 @@
 #include "r0drv/alloc-r0drv.h"
 
+#undef RTMemTmpAlloc
+#undef RTMemTmpAllocZ
+#undef RTMemTmpFree
+#undef RTMemAlloc
+#undef RTMemAllocZ
+#undef RTMemAllocVar
+#undef RTMemAllocZVar
+#undef RTMemRealloc
+#undef RTMemFree
+#undef RTMemDup
+#undef RTMemDupEx
+
 
 /*******************************************************************************
@@ -131,5 +143,5 @@
     RT_ASSERT_INTS_ON();
 
-    pHdr = rtMemAlloc(cb + RTR0MEM_FENCE_EXTRA, 0);
+    pHdr = rtR0MemAlloc(cb + RTR0MEM_FENCE_EXTRA, 0);
     if (pHdr)
     {
@@ -161,5 +173,5 @@
     RT_ASSERT_INTS_ON();
 
-    pHdr = rtMemAlloc(cb + RTR0MEM_FENCE_EXTRA, RTMEMHDR_FLAG_ZEROED);
+    pHdr = rtR0MemAlloc(cb + RTR0MEM_FENCE_EXTRA, RTMEMHDR_FLAG_ZEROED);
     if (pHdr)
     {
@@ -178,4 +190,42 @@
 
 /**
+ * Wrapper around RTMemAlloc for automatically aligning variable sized
+ * allocations so that the various electric fence heaps works correctly.
+ *
+ * @returns See RTMemAlloc.
+ * @param   cbUnaligned         The unaligned size.
+ */
+RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
+{
+    size_t cbAligned;
+    if (cbUnaligned >= 16)
+        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
+    else
+        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
+    return RTMemAlloc(cbAligned);
+}
+RT_EXPORT_SYMBOL(RTMemAllocVar);
+
+
+/**
+ * Wrapper around RTMemAllocZ for automatically aligning variable sized
+ * allocations so that the various electric fence heaps works correctly.
+ *
+ * @returns See RTMemAllocZ.
+ * @param   cbUnaligned         The unaligned size.
+ */
+RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
+{
+    size_t cbAligned;
+    if (cbUnaligned >= 16)
+        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
+    else
+        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
+    return RTMemAllocZ(cbAligned);
+}
+RT_EXPORT_SYMBOL(RTMemAllocZVar);
+
+
+/**
  * Reallocates memory.
  *
@@ -201,5 +251,5 @@
             if (pHdrOld->cb >= cbNew && pHdrOld->cb - cbNew <= 128)
                 return pvOld;
-            pHdrNew = rtMemAlloc(cbNew + RTR0MEM_FENCE_EXTRA, 0);
+            pHdrNew = rtR0MemAlloc(cbNew + RTR0MEM_FENCE_EXTRA, 0);
             if (pHdrNew)
             {
@@ -217,5 +267,5 @@
                                   RTR0MEM_FENCE_EXTRA, &g_abFence[0]));
 #endif
-                rtMemFree(pHdrOld);
+                rtR0MemFree(pHdrOld);
                 return pHdrNew + 1;
             }
@@ -255,5 +305,5 @@
                           RTR0MEM_FENCE_EXTRA, &g_abFence[0]));
 #endif
-        rtMemFree(pHdr);
+        rtR0MemFree(pHdr);
     }
     else
@@ -279,5 +329,5 @@
 #endif
 
-    pHdr = rtMemAlloc(cb + RTR0MEM_FENCE_EXTRA, RTMEMHDR_FLAG_EXEC);
+    pHdr = rtR0MemAlloc(cb + RTR0MEM_FENCE_EXTRA, RTMEMHDR_FLAG_EXEC);
     if (pHdr)
     {
@@ -317,5 +367,5 @@
                           RTR0MEM_FENCE_EXTRA, &g_abFence[0]));
 #endif
-        rtMemFree(pHdr);
+        rtR0MemFree(pHdr);
     }
     else
Index: trunk/src/VBox/Runtime/r0drv/alloc-r0drv.h
===================================================================
--- trunk/src/VBox/Runtime/r0drv/alloc-r0drv.h	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/alloc-r0drv.h	(revision 28298)
@@ -65,6 +65,6 @@
 
 
-PRTMEMHDR   rtMemAlloc(size_t cb, uint32_t fFlags);
-void        rtMemFree(PRTMEMHDR pHdr);
+PRTMEMHDR   rtR0MemAlloc(size_t cb, uint32_t fFlags);
+void        rtR0MemFree(PRTMEMHDR pHdr);
 
 RT_C_DECLS_END
Index: trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/darwin/alloc-r0drv-darwin.cpp	(revision 28298)
@@ -45,5 +45,5 @@
  * OS specific allocation function.
  */
-PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
+PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)
 {
     PRTMEMHDR pHdr = (PRTMEMHDR)IOMalloc(cb + sizeof(*pHdr));
@@ -64,5 +64,5 @@
  * OS specific free function.
  */
-void rtMemFree(PRTMEMHDR pHdr)
+void rtR0MemFree(PRTMEMHDR pHdr)
 {
     pHdr->u32Magic += 1;
Index: trunk/src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c
===================================================================
--- trunk/src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/freebsd/alloc-r0drv-freebsd.c	(revision 28298)
@@ -50,5 +50,5 @@
 
 
-PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
+PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)
 {
     size_t cbAllocated = cb;
@@ -141,5 +141,5 @@
 
 
-void rtMemFree(PRTMEMHDR pHdr)
+void rtR0MemFree(PRTMEMHDR pHdr)
 {
     pHdr->u32Magic += 1;
Index: trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
===================================================================
--- trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c	(revision 28298)
@@ -115,5 +115,5 @@
  * OS specific allocation function.
  */
-PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
+PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)
 {
     /*
@@ -173,5 +173,5 @@
  * OS specific free function.
  */
-void rtMemFree(PRTMEMHDR pHdr)
+void rtR0MemFree(PRTMEMHDR pHdr)
 {
     pHdr->u32Magic += 1;
Index: trunk/src/VBox/Runtime/r0drv/nt/alloc-r0drv-nt.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/nt/alloc-r0drv-nt.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/nt/alloc-r0drv-nt.cpp	(revision 28298)
@@ -43,5 +43,5 @@
  * OS specific allocation function.
  */
-PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
+PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)
 {
     PRTMEMHDR pHdr = (PRTMEMHDR)ExAllocatePoolWithTag(NonPagedPool, cb + sizeof(*pHdr), IPRT_NT_POOL_TAG);
@@ -60,5 +60,5 @@
  * OS specific free function.
  */
-void rtMemFree(PRTMEMHDR pHdr)
+void rtR0MemFree(PRTMEMHDR pHdr)
 {
     pHdr->u32Magic += 1;
Index: trunk/src/VBox/Runtime/r0drv/os2/alloc-r0drv-os2.cpp
===================================================================
--- trunk/src/VBox/Runtime/r0drv/os2/alloc-r0drv-os2.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/os2/alloc-r0drv-os2.cpp	(revision 28298)
@@ -41,5 +41,5 @@
 
 
-PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
+PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)
 {
     void *pv = NULL;
@@ -58,5 +58,5 @@
 
 
-void rtMemFree(PRTMEMHDR pHdr)
+void rtR0MemFree(PRTMEMHDR pHdr)
 {
     pHdr->u32Magic += 1;
Index: trunk/src/VBox/Runtime/r0drv/solaris/vbi/alloc-r0drv-solaris.c
===================================================================
--- trunk/src/VBox/Runtime/r0drv/solaris/vbi/alloc-r0drv-solaris.c	(revision 28297)
+++ trunk/src/VBox/Runtime/r0drv/solaris/vbi/alloc-r0drv-solaris.c	(revision 28298)
@@ -48,5 +48,5 @@
  * OS specific allocation function.
  */
-PRTMEMHDR rtMemAlloc(size_t cb, uint32_t fFlags)
+PRTMEMHDR rtR0MemAlloc(size_t cb, uint32_t fFlags)
 {
     size_t cbAllocated = cb;
@@ -80,5 +80,5 @@
  * OS specific free function.
  */
-void rtMemFree(PRTMEMHDR pHdr)
+void rtR0MemFree(PRTMEMHDR pHdr)
 {
     pHdr->u32Magic += 1;
Index: trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r3/alloc-ef-cpp.cpp	(revision 28298)
@@ -34,7 +34,7 @@
 #include "alloc-ef.h"
 
-
 #if defined(RTALLOC_EFENCE_CPP) || defined(RTMEM_WRAP_TO_EF_APIS) /* rest of the file */
 
+#include <iprt/asm.h>
 #include <new>
 
@@ -62,5 +62,5 @@
 void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb) throw(std::bad_alloc)
 {
-    void *pv = rtMemAlloc("new", RTMEMTYPE_NEW, cb, ((void **)&cb)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemAlloc("new", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     if (!pv)
         throw std::bad_alloc();
@@ -71,5 +71,5 @@
 void *RT_EF_CDECL operator new(RT_EF_SIZE_T cb, const std::nothrow_t &) throw()
 {
-    void *pv = rtMemAlloc("new nothrow", RTMEMTYPE_NEW, cb, ((void **)&cb)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemAlloc("new nothrow", RTMEMTYPE_NEW, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     return pv;
 }
@@ -78,5 +78,5 @@
 void RT_EF_CDECL operator delete(void *pv) throw()
 {
-    rtMemFree("delete", RTMEMTYPE_DELETE, pv, ((void **)&pv)[-1], 0, NULL, NULL);
+    rtR3MemFree("delete", RTMEMTYPE_DELETE, pv, ASMReturnAddress(), NULL, 0, NULL);
 }
 
@@ -84,5 +84,5 @@
 void RT_EF_CDECL operator delete(void * pv, const std::nothrow_t &) throw()
 {
-    rtMemFree("delete nothrow", RTMEMTYPE_DELETE, pv, ((void **)&pv)[-1], 0, NULL, NULL);
+    rtR3MemFree("delete nothrow", RTMEMTYPE_DELETE, pv, ASMReturnAddress(), NULL, 0, NULL);
 }
 
@@ -98,5 +98,5 @@
 void *RT_EF_CDECL operator new[](RT_EF_SIZE_T cb) throw(std::bad_alloc)
 {
-    void *pv = rtMemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, ((void **)&cb)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemAlloc("new[]", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     if (!pv)
         throw std::bad_alloc();
@@ -107,5 +107,5 @@
 void * RT_EF_CDECL operator new[](RT_EF_SIZE_T cb, const std::nothrow_t &) throw()
 {
-    void *pv = rtMemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, ((void **)&cb)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemAlloc("new[] nothrow", RTMEMTYPE_NEW_ARRAY, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
     return pv;
 }
@@ -114,5 +114,5 @@
 void RT_EF_CDECL operator delete[](void * pv) throw()
 {
-    rtMemFree("delete[]", RTMEMTYPE_DELETE_ARRAY, pv, ((void **)&pv)[-1], 0, NULL, NULL);
+    rtR3MemFree("delete[]", RTMEMTYPE_DELETE_ARRAY, pv, ASMReturnAddress(), NULL, 0, NULL);
 }
 
@@ -120,5 +120,5 @@
 void RT_EF_CDECL operator delete[](void *pv, const std::nothrow_t &) throw()
 {
-    rtMemFree("delete[] nothrow", RTMEMTYPE_DELETE_ARRAY, pv, ((void **)&pv)[-1], 0, NULL, NULL);
+    rtR3MemFree("delete[] nothrow", RTMEMTYPE_DELETE_ARRAY, pv, ASMReturnAddress(), NULL, 0, NULL);
 }
 
Index: trunk/src/VBox/Runtime/r3/alloc-ef.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/alloc-ef.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r3/alloc-ef.cpp	(revision 28298)
@@ -92,5 +92,5 @@
  * Log an event.
  */
-static inline void rtmemLog(const char *pszOp, const char *pszFormat, ...)
+DECLINLINE(void) rtmemLog(const char *pszOp, const char *pszFormat, ...)
 {
 #if 0
@@ -109,5 +109,5 @@
  * Aquires the lock.
  */
-static inline void rtmemBlockLock(void)
+DECLINLINE(void) rtmemBlockLock(void)
 {
     unsigned c = 0;
@@ -120,5 +120,5 @@
  * Releases the lock.
  */
-static inline void rtmemBlockUnlock(void)
+DECLINLINE(void) rtmemBlockUnlock(void)
 {
     Assert(g_BlocksLock == 1);
@@ -130,14 +130,16 @@
  * Creates a block.
  */
-static inline PRTMEMBLOCK rtmemBlockCreate(RTMEMTYPE enmType, size_t cb, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction)
+DECLINLINE(PRTMEMBLOCK) rtmemBlockCreate(RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
+                                         void *pvCaller, RT_SRC_POS_DECL)
 {
     PRTMEMBLOCK pBlock = (PRTMEMBLOCK)malloc(sizeof(*pBlock));
     if (pBlock)
     {
-        pBlock->enmType = enmType;
-        pBlock->cb = cb;
-        pBlock->pvCaller = pvCaller;
-        pBlock->iLine = iLine;
-        pBlock->pszFile = pszFile;
+        pBlock->enmType     = enmType;
+        pBlock->cbUnaligned = cbUnaligned;
+        pBlock->cbAligned   = cbAligned;
+        pBlock->pvCaller    = pvCaller;
+        pBlock->iLine       = iLine;
+        pBlock->pszFile     = pszFile;
         pBlock->pszFunction = pszFunction;
     }
@@ -149,5 +151,5 @@
  * Frees a block.
  */
-static inline void rtmemBlockFree(PRTMEMBLOCK pBlock)
+DECLINLINE(void) rtmemBlockFree(PRTMEMBLOCK pBlock)
 {
     free(pBlock);
@@ -158,5 +160,5 @@
  * Insert a block from the tree.
  */
-static inline void rtmemBlockInsert(PRTMEMBLOCK pBlock, void *pv)
+DECLINLINE(void) rtmemBlockInsert(PRTMEMBLOCK pBlock, void *pv)
 {
     pBlock->Core.Key = pv;
@@ -171,5 +173,5 @@
  * Remove a block from the tree and returns it to the caller.
  */
-static inline PRTMEMBLOCK rtmemBlockRemove(void *pv)
+DECLINLINE(PRTMEMBLOCK) rtmemBlockRemove(void *pv)
 {
     rtmemBlockLock();
@@ -182,5 +184,5 @@
  * Gets a block.
  */
-static inline PRTMEMBLOCK rtmemBlockGet(void *pv)
+DECLINLINE(PRTMEMBLOCK) rtmemBlockGet(void *pv)
 {
     rtmemBlockLock();
@@ -196,7 +198,8 @@
 {
     PRTMEMBLOCK pBlock = (PRTMEMBLOCK)pNode;
-    fprintf(stderr, "%p %08lx %p\n",
+    fprintf(stderr, "%p %08lx(+%02lx) %p\n",
             pBlock->Core.Key,
-            (long)pBlock->cb,
+            (unsigned long)pBlock->cbUnaligned,
+            (unsigned long)(pBlock->cbAligned - pBlock->cbUnaligned),
             pBlock->pvCaller);
     return 0;
@@ -210,5 +213,5 @@
 void RTMemDump(void)
 {
-    fprintf(stderr, "address  size     caller\n");
+    fprintf(stderr, "address  size(alg)     caller\n");
     RTAvlPVDoWithAll(&g_BlocksTree, true, RTMemDumpOne, NULL);
 }
@@ -219,7 +222,7 @@
  * Insert a delayed block.
  */
-static inline void rtmemBlockDelayInsert(PRTMEMBLOCK pBlock)
-{
-    size_t cbBlock = RT_ALIGN_Z(pBlock->cb, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
+DECLINLINE(void) rtmemBlockDelayInsert(PRTMEMBLOCK pBlock)
+{
+    size_t cbBlock = RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
     pBlock->Core.pRight = NULL;
     pBlock->Core.pLeft = NULL;
@@ -243,5 +246,5 @@
  * Removes a delayed block.
  */
-static inline PRTMEMBLOCK rtmemBlockDelayRemove(void)
+DECLINLINE(PRTMEMBLOCK) rtmemBlockDelayRemove(void)
 {
     PRTMEMBLOCK pBlock = NULL;
@@ -257,5 +260,5 @@
             else
                 g_pBlocksDelayHead = NULL;
-            g_cbBlocksDelay -= RT_ALIGN_Z(pBlock->cb, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
+            g_cbBlocksDelay -= RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
         }
     }
@@ -273,5 +276,6 @@
  * Internal allocator.
  */
-RTDECL(void *) rtMemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cb, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction)
+RTDECL(void *) rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
+                            void *pvCaller, RT_SRC_POS_DECL)
 {
     /*
@@ -284,5 +288,5 @@
         return NULL;
     }
-    if (!cb)
+    if (!cbUnaligned)
     {
 #if 0
@@ -290,12 +294,13 @@
         return NULL;
 #else
-        cb = 1;
-#endif
-    }
+        cbAligned = cbUnaligned = 1;
+#endif
+    }
+
 #ifndef RTALLOC_EFENCE_IN_FRONT
     /* Alignment decreases fence accuracy, but this is at least partially
      * counteracted by filling and checking the alignment padding. When the
      * fence is in front then then no extra alignment is needed. */
-    size_t cbAligned = RT_ALIGN_Z(cb, RTALLOC_EFENCE_ALIGNMENT);
+    cbAligned = RT_ALIGN_Z(cbAligned, RTALLOC_EFENCE_ALIGNMENT);
 #endif
 
@@ -304,5 +309,5 @@
      * Allocate the trace block.
      */
-    PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cb, pvCaller, iLine, pszFile, pszFunction);
+    PRTMEMBLOCK pBlock = rtmemBlockCreate(enmType, cbUnaligned, cbAligned, pvCaller, RT_SRC_POS_ARGS);
     if (!pBlock)
     {
@@ -315,5 +320,5 @@
      * Allocate a block with page alignment space + the size of the E-fence.
      */
-    size_t  cbBlock = RT_ALIGN_Z(cb, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
+    size_t  cbBlock = RT_ALIGN_Z(cbAligned, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
     void   *pvBlock = RTMemPageAlloc(cbBlock);
     if (pvBlock)
@@ -325,14 +330,14 @@
 #ifdef RTALLOC_EFENCE_IN_FRONT
         void *pvEFence = pvBlock;
-        void *pv = (char *)pvEFence + RTALLOC_EFENCE_SIZE;
+        void *pv       = (char *)pvEFence + RTALLOC_EFENCE_SIZE;
 # ifdef RTALLOC_EFENCE_NOMAN_FILLER
-        memset((char *)pv + cb, RTALLOC_EFENCE_NOMAN_FILLER, cbBlock - RTALLOC_EFENCE_SIZE - cb);
+        memset((char *)pv + cb, RTALLOC_EFENCE_NOMAN_FILLER, cbBlock - RTALLOC_EFENCE_SIZE - cbUnaligned);
 # endif
 #else
         void *pvEFence = (char *)pvBlock + (cbBlock - RTALLOC_EFENCE_SIZE);
-        void *pv = (char *)pvEFence - cbAligned;
+        void *pv       = (char *)pvEFence - cbAligned;
 # ifdef RTALLOC_EFENCE_NOMAN_FILLER
         memset(pvBlock, RTALLOC_EFENCE_NOMAN_FILLER, cbBlock - RTALLOC_EFENCE_SIZE - cbAligned);
-        memset((char *)pv + cb, RTALLOC_EFENCE_NOMAN_FILLER, cbAligned - cb);
+        memset((char *)pv + cbUnaligned, RTALLOC_EFENCE_NOMAN_FILLER, cbAligned - cbUnaligned);
 # endif
 #endif
@@ -348,11 +353,11 @@
 #endif
             if (enmType == RTMEMTYPE_RTMEMALLOCZ)
-                memset(pv, 0, cb);
+                memset(pv, 0, cbUnaligned);
 #ifdef RTALLOC_EFENCE_FILLER
             else
-                memset(pv, RTALLOC_EFENCE_FILLER, cb);
-#endif
-
-            rtmemLog(pszOp, "returns %p (pvBlock=%p cbBlock=%#x pvEFence=%p cb=%#x)\n", pv, pvBlock, cbBlock, pvEFence, cb);
+                memset(pv, RTALLOC_EFENCE_FILLER, cbUnaligned);
+#endif
+
+            rtmemLog(pszOp, "returns %p (pvBlock=%p cbBlock=%#x pvEFence=%p cbUnaligned=%#x)\n", pv, pvBlock, cbBlock, pvEFence, cbUnaligned);
             return pv;
         }
@@ -361,5 +366,5 @@
     }
     else
-        rtmemComplain(pszOp, "Failed to allocated %d bytes.\n", cb);
+        rtmemComplain(pszOp, "Failed to allocated %lu (%lu) bytes.\n", (unsigned long)cbBlock, (unsigned long)cbUnaligned);
 
 #ifdef RTALLOC_EFENCE_TRACE
@@ -373,5 +378,5 @@
  * Internal free.
  */
-RTDECL(void) rtMemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction)
+RTDECL(void) rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL)
 {
     /*
@@ -396,5 +401,5 @@
     {
         if (gfRTMemFreeLog)
-            RTLogPrintf("RTMem %s: pv=%p pvCaller=%p cb=%#x\n", pszOp, pv, pvCaller, pBlock->cb);
+            RTLogPrintf("RTMem %s: pv=%p pvCaller=%p cbUnaligned=%#x\n", pszOp, pv, pvCaller, pBlock->cbUnaligned);
 
 # ifdef RTALLOC_EFENCE_NOMAN_FILLER
@@ -408,12 +413,11 @@
 #  else
         /* Alignment must match allocation alignment in rtMemAlloc(). */
-        size_t cbAligned = RT_ALIGN_Z(pBlock->cb, RTALLOC_EFENCE_ALIGNMENT);
-        void  *pvWrong   = ASMMemIsAll8((char *)pv + pBlock->cb,
-                                        cbAligned - pBlock->cb,
+        void  *pvWrong   = ASMMemIsAll8((char *)pv + pBlock->cbUnaligned,
+                                        pBlock->cbAligned - pBlock->cbUnaligned,
                                         RTALLOC_EFENCE_NOMAN_FILLER);
         if (pvWrong)
             RTAssertDoPanic();
         pvWrong = ASMMemIsAll8((void *)((uintptr_t)pv & ~PAGE_OFFSET_MASK),
-                               RT_ALIGN_Z(cbAligned, PAGE_SIZE) - cbAligned,
+                               RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) - pBlock->cbAligned,
                                RTALLOC_EFENCE_NOMAN_FILLER);
 #  endif
@@ -426,5 +430,5 @@
          * Fill the user part of the block.
          */
-        memset(pv, RTALLOC_EFENCE_FREE_FILL, pBlock->cb);
+        memset(pv, RTALLOC_EFENCE_FREE_FILL, pBlock->cbUnaligned);
 # endif
 
@@ -434,5 +438,5 @@
          * That means we'll expand the E-fence to cover the entire block.
          */
-        int rc = RTMemProtect(pv, pBlock->cb, RTMEM_PROT_NONE);
+        int rc = RTMemProtect(pv, pBlock->cbAligned, RTMEM_PROT_NONE);
         if (RT_SUCCESS(rc))
         {
@@ -445,9 +449,9 @@
                 pv = pBlock->Core.Key;
 #  ifdef RTALLOC_EFENCE_IN_FRONT
-                void *pvBlock = (char *)pv - RTALLOC_EFENCE_SIZE;
+                void  *pvBlock = (char *)pv - RTALLOC_EFENCE_SIZE;
 #  else
-                void *pvBlock = (void *)((uintptr_t)pv & ~PAGE_OFFSET_MASK);
+                void  *pvBlock = (void *)((uintptr_t)pv & ~PAGE_OFFSET_MASK);
 #  endif
-                size_t cbBlock = RT_ALIGN_Z(pBlock->cb, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
+                size_t cbBlock = RT_ALIGN_Z(pBlock->cbAligned, PAGE_SIZE) + RTALLOC_EFENCE_SIZE;
                 rc = RTMemProtect(pvBlock, cbBlock, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
                 if (RT_SUCCESS(rc))
@@ -503,5 +507,5 @@
  * Internal realloc.
  */
-RTDECL(void *) rtMemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction)
+RTDECL(void *) rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL)
 {
     /*
@@ -509,8 +513,8 @@
      */
     if (!pvOld)
-        return rtMemAlloc(pszOp, enmType, cbNew, pvCaller, iLine, pszFile, pszFunction);
+        return rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pvCaller, RT_SRC_POS_ARGS);
     if (!cbNew)
     {
-        rtMemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, iLine, pszFile, pszFunction);
+        rtR3MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, RT_SRC_POS_ARGS);
         return NULL;
     }
@@ -524,9 +528,9 @@
     if (pBlock)
     {
-        void *pvRet = rtMemAlloc(pszOp, enmType, cbNew, pvCaller, iLine, pszFile, pszFunction);
+        void *pvRet = rtR3MemAlloc(pszOp, enmType, cbNew, cbNew, pvCaller, RT_SRC_POS_ARGS);
         if (pvRet)
         {
-            memcpy(pvRet, pvOld, RT_MIN(cbNew, pBlock->cb));
-            rtMemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, iLine, pszFile, pszFunction);
+            memcpy(pvRet, pvOld, RT_MIN(cbNew, pBlock->cbUnaligned));
+            rtR3MemFree(pszOp, RTMEMTYPE_RTMEMREALLOC, pvOld, pvCaller, RT_SRC_POS_ARGS);
         }
         return pvRet;
@@ -547,75 +551,36 @@
 
 
-/**
- * Same as RTMemTmpAlloc() except that it's fenced.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfTmpAlloc(size_t cb) RT_NO_THROW
-{
-    return RTMemEfAlloc(cb);
-}
-
-
-/**
- * Same as RTMemTmpAllocZ() except that it's fenced.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb) RT_NO_THROW
-{
-    return RTMemEfAllocZ(cb);
-}
-
-
-/**
- * Same as RTMemTmpFree() except that it's for fenced memory.
- *
- * @param   pv      Pointer to memory block.
- */
-RTDECL(void)    RTMemEfTmpFree(void *pv) RT_NO_THROW
-{
-    RTMemEfFree(pv);
-}
-
-
-/**
- * Same as RTMemAlloc() except that it's fenced.
- *
- * @returns Pointer to the allocated memory. Free with RTMemEfFree().
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAlloc(size_t cb) RT_NO_THROW
-{
-    return rtMemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, ((void **)&cb)[-1], 0, NULL, NULL);
-}
-
-
-/**
- * Same as RTMemAllocZ() except that it's fenced.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cb      Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAllocZ(size_t cb) RT_NO_THROW
-{
-    return rtMemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, ((void **)&cb)[-1], 0, NULL, NULL);
-}
-
-
-/**
- * Same as RTMemAllocVar() except that it's fenced.
- *
- * @returns Pointer to the allocated memory. Free with RTMemEfFree().
- * @returns NULL on failure.
- * @param   cbUnaligned Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned) RT_NO_THROW
+RTDECL(void *)  RTMemEfTmpAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void)    RTMemEfTmpFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    if (pv)
+        rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAlloc(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZ(size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAllocVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW
 {
     size_t cbAligned;
@@ -624,16 +589,9 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return rtMemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbAligned, ((void **)&cbUnaligned)[-1], 0, NULL, NULL);
-}
-
-
-/**
- * Same as RTMemAllocZVar() except that it's fenced.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   cbUnaligned Size in bytes of the memory block to allocate.
- */
-RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned) RT_NO_THROW
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZVar(size_t cbUnaligned, RT_SRC_POS_DECL) RT_NO_THROW
 {
     size_t cbAligned;
@@ -642,45 +600,24 @@
     else
         cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
-    return rtMemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbAligned, ((void **)&cbUnaligned)[-1], 0, NULL, NULL);
-}
-
-
-/**
- * Same as RTMemRealloc() except that it's fenced.
- *
- * @returns Pointer to the allocated memory.
- * @returns NULL on failure.
- * @param   pvOld   The memory block to reallocate.
- * @param   cbNew   The new block size (in bytes).
- */
-RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew) RT_NO_THROW
-{
-    return rtMemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ((void **)&pvOld)[-1], 0, NULL, NULL);
-}
-
-
-/**
- * Free memory allocated by any of the RTMemEf* allocators.
- *
- * @param   pv      Pointer to memory block.
- */
-RTDECL(void)    RTMemEfFree(void *pv) RT_NO_THROW
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void)    RTMemEfFree(void *pv, RT_SRC_POS_DECL) RT_NO_THROW
 {
     if (pv)
-        rtMemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ((void **)&pv)[-1], 0, NULL, NULL);
-}
-
-
-/**
- * Same as RTMemDup() except that it's fenced.
- *
- * @returns New heap block with the duplicate data.
- * @returns NULL if we're out of memory.
- * @param   pvSrc   The memory to duplicate.
- * @param   cb      The amount of memory to duplicate.
- */
-RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb) RT_NO_THROW
-{
-    void *pvDst = RTMemEfAlloc(cb);
+        rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), RT_SRC_POS_ARGS);
+}
+
+
+RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cb, RT_SRC_POS_ARGS);
     if (pvDst)
         memcpy(pvDst, pvSrc, cb);
@@ -689,16 +626,7 @@
 
 
-/**
- * Same as RTMemDupEx except that it's fenced.
- *
- * @returns New heap block with the duplicate data.
- * @returns NULL if we're out of memory.
- * @param   pvSrc   The memory to duplicate.
- * @param   cbSrc   The amount of memory to duplicate.
- * @param   cbExtra The amount of extra memory to allocate and zero.
- */
-RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW
-{
-    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra);
+RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra, RT_SRC_POS_DECL) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, RT_SRC_POS_ARGS);
     if (pvDst)
     {
@@ -709,2 +637,100 @@
 }
 
+
+
+
+/*
+ *
+ * The NP (no position) versions.
+ *
+ */
+
+
+
+RTDECL(void *)  RTMemEfTmpAllocNP(size_t cb) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAlloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfTmpAllocZNP(size_t cb) RT_NO_THROW
+{
+    return rtR3MemAlloc("TmpAllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void)    RTMemEfTmpFreeNP(void *pv) RT_NO_THROW
+{
+    if (pv)
+        rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocNP(size_t cb) RT_NO_THROW
+{
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZNP(size_t cb) RT_NO_THROW
+{
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocVarNP(size_t cbUnaligned) RT_NO_THROW
+{
+    size_t cbAligned;
+    if (cbUnaligned >= 16)
+        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
+    else
+        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
+    return rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfAllocZVarNP(size_t cbUnaligned) RT_NO_THROW
+{
+    size_t cbAligned;
+    if (cbUnaligned >= 16)
+        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
+    else
+        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
+    return rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *)  RTMemEfReallocNP(void *pvOld, size_t cbNew) RT_NO_THROW
+{
+    return rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void)    RTMemEfFreeNP(void *pv) RT_NO_THROW
+{
+    if (pv)
+        rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL);
+}
+
+
+RTDECL(void *) RTMemEfDupNP(const void *pvSrc, size_t cb) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cb, NULL, 0, NULL);
+    if (pvDst)
+        memcpy(pvDst, pvSrc, cb);
+    return pvDst;
+}
+
+
+RTDECL(void *) RTMemEfDupExNP(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW
+{
+    void *pvDst = RTMemEfAlloc(cbSrc + cbExtra, NULL, 0, NULL);
+    if (pvDst)
+    {
+        memcpy(pvDst, pvSrc, cbSrc);
+        memset((uint8_t *)pvDst + cbSrc, 0, cbExtra);
+    }
+    return pvDst;
+}
+
+
Index: trunk/src/VBox/Runtime/r3/alloc-ef.h
===================================================================
--- trunk/src/VBox/Runtime/r3/alloc-ef.h	(revision 28297)
+++ trunk/src/VBox/Runtime/r3/alloc-ef.h	(revision 28298)
@@ -45,5 +45,5 @@
  * RTMemAllocZ(), RTMemRealloc(), RTMemTmpAlloc() and RTMemTmpAllocZ().
  */
-#if defined(DEBUG_bird)
+#if 0
 # define RTALLOC_USE_EFENCE
 #endif
@@ -166,6 +166,8 @@
     /** Allocation type. */
     RTMEMTYPE       enmType;
-    /** The size of the block. */
-    size_t          cb;
+    /** The unaligned size of the block. */
+    size_t          cbUnaligned;
+    /** The aligned size of the block. */
+    size_t          cbAligned;
     /** The return address of the allocator function. */
     void           *pvCaller;
@@ -185,7 +187,8 @@
 ******************************************************************************/
 RT_C_DECLS_BEGIN
-RTDECL(void *)  rtMemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cb, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction);
-RTDECL(void *)  rtMemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction);
-RTDECL(void)    rtMemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, unsigned iLine, const char *pszFile, const char *pszFunction);
+RTDECL(void *)  rtR3MemAlloc(const char *pszOp, RTMEMTYPE enmType, size_t cbUnaligned, size_t cbAligned,
+                             void *pvCaller, RT_SRC_POS_DECL);
+RTDECL(void *)  rtR3MemRealloc(const char *pszOp, RTMEMTYPE enmType, void *pvOld, size_t cbNew, void *pvCaller, RT_SRC_POS_DECL);
+RTDECL(void)    rtR3MemFree(const char *pszOp, RTMEMTYPE enmType, void *pv, void *pvCaller, RT_SRC_POS_DECL);
 RT_C_DECLS_END
 
Index: trunk/src/VBox/Runtime/r3/alloc.cpp
===================================================================
--- trunk/src/VBox/Runtime/r3/alloc.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/r3/alloc.cpp	(revision 28298)
@@ -44,4 +44,5 @@
 #include "alloc-ef.h"
 #include <iprt/alloc.h>
+#include <iprt/asm.h>
 #include <iprt/assert.h>
 #include <iprt/param.h>
@@ -49,4 +50,16 @@
 
 #include <stdlib.h>
+
+#undef RTMemTmpAlloc
+#undef RTMemTmpAllocZ
+#undef RTMemTmpFree
+#undef RTMemAlloc
+#undef RTMemAllocZ
+#undef RTMemAllocVar
+#undef RTMemAllocZVar
+#undef RTMemRealloc
+#undef RTMemFree
+#undef RTMemDup
+#undef RTMemDupEx
 
 
@@ -105,5 +118,5 @@
 {
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtMemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, ((void **)&cb)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemAlloc("Alloc", RTMEMTYPE_RTMEMALLOC, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
 
 #else /* !RTALLOC_USE_EFENCE */
@@ -135,5 +148,5 @@
 {
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtMemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, ((void **)&cb)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemAlloc("AllocZ", RTMEMTYPE_RTMEMALLOCZ, cb, cb, ASMReturnAddress(), NULL, 0, NULL);
 
 #else /* !RTALLOC_USE_EFENCE */
@@ -153,4 +166,50 @@
 
 /**
+ * Wrapper around RTMemAlloc for automatically aligning variable sized
+ * allocations so that the various electric fence heaps works correctly.
+ *
+ * @returns See RTMemAlloc.
+ * @param   cbUnaligned         The unaligned size.
+ */
+RTDECL(void *) RTMemAllocVar(size_t cbUnaligned)
+{
+    size_t cbAligned;
+    if (cbUnaligned >= 16)
+        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
+    else
+        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
+#ifdef RTALLOC_USE_EFENCE
+    void *pv = RTMemAlloc(cbAligned);
+#else
+    void *pv = rtR3MemAlloc("AllocVar", RTMEMTYPE_RTMEMALLOC, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
+#endif
+    return pv;
+}
+
+
+/**
+ * Wrapper around RTMemAllocZ for automatically aligning variable sized
+ * allocations so that the various electric fence heaps works correctly.
+ *
+ * @returns See RTMemAllocZ.
+ * @param   cbUnaligned         The unaligned size.
+ */
+RTDECL(void *) RTMemAllocZVar(size_t cbUnaligned)
+{
+    size_t cbAligned;
+    if (cbUnaligned >= 16)
+        cbAligned = RT_ALIGN_Z(cbUnaligned, 16);
+    else
+        cbAligned = RT_ALIGN_Z(cbUnaligned, sizeof(void *));
+#ifdef RTALLOC_USE_EFENCE
+    void *pv = RTMemAllocZ(cbAligned);
+#else
+    void *pv = rtR3MemAlloc("AllocZVar", RTMEMTYPE_RTMEMALLOCZ, cbUnaligned, cbAligned, ASMReturnAddress(), NULL, 0, NULL);
+#endif
+    return pv;
+}
+
+
+/**
  * Reallocates memory.
  *
@@ -163,5 +222,5 @@
 {
 #ifdef RTALLOC_USE_EFENCE
-    void *pv = rtMemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ((void **)&pvOld)[-1], 0, NULL, NULL);
+    void *pv = rtR3MemRealloc("Realloc", RTMEMTYPE_RTMEMREALLOC, pvOld, cbNew, ASMReturnAddress(), NULL, 0, NULL);
 
 #else /* !RTALLOC_USE_EFENCE */
@@ -187,5 +246,5 @@
     if (pv)
 #ifdef RTALLOC_USE_EFENCE
-        rtMemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ((void **)&pv)[-1], 0, NULL, NULL);
+        rtR3MemFree("Free", RTMEMTYPE_RTMEMFREE, pv, ASMReturnAddress(), NULL, 0, NULL);
 #else
         free(pv);
Index: trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/testcase/tstMemAutoPtr.cpp	(revision 28298)
@@ -113,5 +113,5 @@
         g_cErrors++;
     }
-    RTMemEfFree(aMem);
+    RTMemEfFreeNP(aMem);
     g_cFrees++;
 }
@@ -165,5 +165,5 @@
      */
     {
-        RTMemAutoPtr<char, RTMemEfAutoFree<char>, RTMemEfRealloc> Electric(10);
+        RTMemAutoPtr<char, RTMemEfAutoFree<char>, RTMemEfReallocNP> Electric(10);
         CHECK_EXPR(Electric.get() != NULL);
         Electric[0] = '0';
@@ -182,5 +182,5 @@
     g_cFrees = 0;
     {
-        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfRealloc> FreeIt(128);
+        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt(128);
         FreeIt[127] = '0';
     }
@@ -189,5 +189,5 @@
     g_cFrees = 0;
     {
-        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfRealloc> FreeIt2(128);
+        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt2(128);
         FreeIt2[127] = '1';
         FreeIt2.reset();
@@ -200,7 +200,7 @@
     g_cFrees = 0;
     {
-        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfRealloc> DontFreeIt(256);
+        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> DontFreeIt(256);
         DontFreeIt[255] = '0';
-        RTMemEfFree(DontFreeIt.release());
+        RTMemEfFreeNP(DontFreeIt.release());
     }
     CHECK_EXPR(g_cFrees == 0);
@@ -208,5 +208,5 @@
     g_cFrees = 0;
     {
-        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfRealloc> FreeIt3(128);
+        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt3(128);
         FreeIt3[127] = '0';
         CHECK_EXPR(FreeIt3.realloc(128));
@@ -223,5 +223,5 @@
     g_cFrees = 0;
     {
-        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfRealloc> FreeIt4;
+        RTMemAutoPtr<char, tstMemAutoPtrDestructorCounter, RTMemEfReallocNP> FreeIt4;
         CHECK_EXPR(FreeIt4.alloc(123));
         CHECK_EXPR(FreeIt4.realloc(543));
Index: trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp	(revision 28297)
+++ trunk/src/VBox/Runtime/testcase/tstRTMemEf.cpp	(revision 28298)
@@ -51,5 +51,5 @@
      * the word after the allocated block and the word before. One of them
      * will crash no matter whether the fence is at the bottom or on top. */
-    int32_t *p = (int32_t *)RTMemEfAlloc(sizeof(int32_t));
+    int32_t *p = (int32_t *)RTMemEfAllocNP(sizeof(int32_t));
     RTPrintf("tstRTMemAllocEfAccess: allocated int32_t at %#p\n", p);
     RTPrintf("tstRTMemAllocEfAccess: triggering buffer overrun...\n");
