#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
#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);
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();
if (pMem) {
PMEMORY_BLOCK_HEADER ptr = (PMEMORY_BLOCK_HEADER)(((char*)pMem)-sizeof(MEMORY_BLOCK_HEADER));
if (ptr->owner != this) {
-#if 0
- int *nowhere = NULL;
- *nowhere = 0;
-#else
if (ptr->owner) {
- ptr->owner->Free(pMem);
+#if 1
+ dTHX;
+ int *nowhere = NULL;
+ Perl_warn(aTHX_ "Free to wrong pool %p not %p",this,ptr->owner);
+ *nowhere = 0; /* this segfault is deliberate,
+ so you can see the stack trace */
+#else
+ ptr->owner->Free(pMem);
+#endif
}
return;
-#endif
}
GetLock();
UnlinkBlock(ptr);
if(ptr == m_heaps[index].base + (int)m_heaps[index].len) {
/*
* The new block is contiguous with a previously allocated heap area. Add its
- * length to that of the previous heap. Merge it with the the dummy end-of-heap
+ * length to that of the previous heap. Merge it with the dummy end-of-heap
* area marker of the previous heap.
*/
m_heaps[index].len += size;