[llvm-commits] CVS: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 19 23:26:02 PST 2004


Changes in directory poolalloc/runtime/FL2Allocator:

FreeListAllocator.cpp updated: 1.2 -> 1.3

---
Log message:

Tolerate pool_free(0).  pool_alloc(0) will now return a null pointer to allow
the pool allocator's realloc implementation to work effectively.


---
Diffs of the changes:  (+3 -4)

Index: poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp
diff -u poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.2 poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.3
--- poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp:1.2	Thu Feb 19 23:05:14 2004
+++ poolalloc/runtime/FL2Allocator/FreeListAllocator.cpp	Thu Feb 19 23:25:48 2004
@@ -101,10 +101,8 @@
 
 void *poolalloc(PoolTy *Pool, unsigned NumBytes) {
   assert(Pool && "Null pool pointer passed in to poolalloc!\n");
-  if (NumBytes == 0)
-    NumBytes = 4;
-  else
-    NumBytes = (NumBytes+3) & ~3;  // Round up to 4 bytes...
+  if (NumBytes == 0) return 0;
+  NumBytes = (NumBytes+3) & ~3;  // Round up to 4 bytes...
 
   // Fast path.  In the common case, we can allocate a portion of the node at
   // the front of the free list.
@@ -178,6 +176,7 @@
 
 void poolfree(PoolTy *Pool, void *Node) {
   assert(Pool && "Null pool pointer passed in to poolfree!\n");
+  if (Node == 0) return;
 
   // Check to see how many elements were allocated to this node...
   FreedNodeHeader *FNH = (FreedNodeHeader*)((char*)Node-sizeof(NodeHeader));





More information about the llvm-commits mailing list