This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Wrap argument lists in perl{api,intern}.pod
[perl5.git] / win32 / vmem.h
index 31aa07e..460f557 100644 (file)
@@ -21,7 +21,9 @@
 #ifndef ___VMEM_H_INC___
 #define ___VMEM_H_INC___
 
+#ifndef UNDER_CE
 #define _USE_MSVCRT_MEM_ALLOC
+#endif
 #define _USE_LINKED_LIST
 
 // #define _USE_BUDDY_BLOCKS
@@ -162,6 +164,10 @@ void* VMem::Malloc(size_t size)
 #ifdef _USE_LINKED_LIST
     GetLock();
     PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)m_pmalloc(size+sizeof(MEMORY_BLOCK_HEADER));
+    if (!ptr) {
+       FreeLock();
+       return NULL;
+    }
     LinkBlock(ptr);
     FreeLock();
     return (ptr+1);
@@ -185,6 +191,10 @@ void* VMem::Realloc(void* pMem, size_t size)
     PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)(((char*)pMem)-sizeof(MEMORY_BLOCK_HEADER));
     UnlinkBlock(ptr);
     ptr = (PMEMORY_BLOCK_HEADER)m_prealloc(ptr, size+sizeof(MEMORY_BLOCK_HEADER));
+    if (!ptr) {
+       FreeLock();
+       return NULL;
+    }
     LinkBlock(ptr);
     FreeLock();
 
@@ -205,7 +215,8 @@ void VMem::Free(void* pMem)
                dTHX;
                int *nowhere = NULL;
                Perl_warn(aTHX_ "Free to wrong pool %p not %p",this,ptr->owner);
-               *nowhere = 0;
+               *nowhere = 0; /* this segfault is deliberate, 
+                                so you can see the stack trace */
 #else
                 ptr->owner->Free(pMem);        
 #endif