|
From: rossta <gra...@li...> - 2004-01-15 07:35:56
|
rossta Wed Jan 14 23:35:56 2004 EDT
Modified files:
/grapevine/cpp Allocator.h
Log:
MSVC version runs now, but it leaks memory like crazy. Needs research
Index: grapevine/cpp/Allocator.h
diff -u grapevine/cpp/Allocator.h:1.13 grapevine/cpp/Allocator.h:1.14
--- grapevine/cpp/Allocator.h:1.13 Tue Jan 13 22:19:26 2004
+++ grapevine/cpp/Allocator.h Wed Jan 14 23:35:55 2004
@@ -1,4 +1,4 @@
-// $Id: Allocator.h,v 1.13 2004/01/14 06:19:26 rossta Exp $
+// $Id: Allocator.h,v 1.14 2004/01/15 07:35:55 rossta Exp $
#ifndef _ALLOCATOR_H_
#define _ALLOCATOR_H_
@@ -75,9 +75,9 @@
assert(idx < GRAPEVINE_BLOCKSIZES);
void*& freeList = grapevineFreeLists[idx];
- if (p != NULL) {
+// if (p != NULL) {
*((void**)p) = freeList;
- }
+// }
freeList = p;
}
@@ -113,7 +113,7 @@
free(p);
}
-#ifndef _MSC_VER
+// #ifndef _MSC_VER
template <class T>
class grapevine_allocator
@@ -136,7 +136,11 @@
void deallocate(void* p, size_type n)
{
- assert(p != 0);
+#ifdef _MSC_VER
+ if (p == 0)
+ return;
+#endif
+ assert(p != 0);
grapevineFreeBig(p, n * sizeof(T));
}
@@ -174,17 +178,28 @@
{
typedef grapevine_allocator<U> other;
};
+
+#ifndef _MSC_VER
template <class U> grapevine_allocator(const grapevine_allocator<U>&) {}
- template <class U> grapevine_allocator& operator=(const grapevine_allocator<U>&)
- {
- return *this;
- }
+ template <class U> grapevine_allocator& operator=(const grapevine_allocator<U>&) { return *this; }
+
+#else
+ typedef _PDFT difference_type;
+
+ char _FARQ *_Charalloc(size_type _N)
+ {
+ return reinterpret_cast<char _FARQ *>(grapevineAllocateBig((difference_type)_N * sizeof(T)));
+ }
+
+#endif
};
+
+#if 0
-#else // _MSC_VER
+// #else // _MSC_VER
/*
@@ -300,7 +315,9 @@
void deallocate(void _FARQ *_P, size_type _N)
{
-// assert(_P != 0);
+ if (_P == NULL)
+ return;
+ assert(_P != 0);
grapevineFreeBig(_P, _N * sizeof(_Ty));
}
|