00001 /* 00002 * $Revision: 2299 $ 00003 * 00004 * last checkin: 00005 * $Author: gutwenger $ 00006 * $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 00007 ***************************************************************/ 00008 00044 #ifdef _MSC_VER 00045 #pragma once 00046 #endif 00047 00048 #ifndef OGDF_MALLOC_MEMORY_ALLOCATOR_H 00049 #define OGDF_MALLOC_MEMORY_ALLOCATOR_H 00050 00051 00052 namespace ogdf { 00053 00055 class OGDF_EXPORT MallocMemoryAllocator { 00056 public: 00057 00058 MallocMemoryAllocator() { } 00059 ~MallocMemoryAllocator() { } 00060 00061 00062 static void init() { } 00063 static void initThread() { } 00064 static void cleanup() { } 00065 00066 static bool checkSize(size_t /* nBytes */) { return true; } 00067 00069 static void *allocate(size_t nBytes, const char *, int) { return allocate(nBytes); } 00070 00072 static void *allocate(size_t nBytes) 00073 { 00074 void *p = malloc(nBytes); 00075 if (OGDF_UNLIKELY(p == 0)) OGDF_THROW(ogdf::InsufficientMemoryException); 00076 return p; 00077 } 00078 00079 00081 static void deallocate(size_t /* nBytes */, void *p) { free(p); } 00082 00084 00088 static void deallocateList(size_t /* nBytes */, void *pHead, void *pTail) 00089 { 00090 MemElemPtr q, pStop = MemElemPtr(pTail)->m_next; 00091 while (pHead != pStop) { 00092 q = MemElemPtr(pHead)->m_next; 00093 free(pHead); 00094 pHead = q; 00095 } 00096 } 00097 00098 static void flushPool() { } 00099 static void flushPool(__uint16 /* nBytes */) { } 00100 00102 static size_t memoryAllocatedInBlocks() { return 0; } 00103 00105 static size_t memoryInFreelist() { return 0; } 00106 }; 00107 00108 } // namespace ogdf 00109 00110 #endif