[llvm-commits] CVS: poolalloc/runtime/PoolAllocator/PageManager.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Nov 7 17:57:09 PST 2003
Changes in directory poolalloc/runtime/PoolAllocator:
PageManager.cpp updated: 1.2 -> 1.3
---
Log message:
Do not use operator new to allocate the vector. This adds a pointless dependency on libstdc++
---
Diffs of the changes: (+8 -2)
Index: poolalloc/runtime/PoolAllocator/PageManager.cpp
diff -u poolalloc/runtime/PoolAllocator/PageManager.cpp:1.2 poolalloc/runtime/PoolAllocator/PageManager.cpp:1.3
--- poolalloc/runtime/PoolAllocator/PageManager.cpp:1.2 Fri Nov 7 11:21:24 2003
+++ poolalloc/runtime/PoolAllocator/PageManager.cpp Fri Nov 7 17:56:01 2003
@@ -25,7 +25,8 @@
// Explicitly use the malloc allocator here, to avoid depending on the C++
// runtime library.
-static std::vector<void*, MallocAllocator<void*> > *FreePages = 0;
+typedef std::vector<void*, MallocAllocator<void*> > FreePagesListType;
+static FreePagesListType *FreePages = 0;
void InitializePageManager() {
if (!PageSize) PageSize = sysconf(_SC_PAGESIZE);
@@ -70,7 +71,12 @@
unsigned NumToAllocate = 10;
char *Ptr = (char*)GetPages(NumToAllocate);
- if (!FreePages) FreePages = new std::vector<void*, MallocAllocator<void*> >();
+ if (!FreePages) {
+ // Avoid using operator new!
+ FreePages = (FreePagesListType*)malloc(sizeof(FreePagesListType));
+ // Use placement new now.
+ new (FreePages) std::vector<void*, MallocAllocator<void*> >();
+ }
for (unsigned i = 1; i != NumToAllocate; ++i)
FreePages->push_back(Ptr+i*PageSize);
return Ptr;
More information about the llvm-commits
mailing list