Ticket #208: memdiff.patch
| File memdiff.patch, 1.4 KB (added by , 16 years ago) |
|---|
-
capi/geos_c.cpp
107 107 108 108 static GEOSMessageHandler NOTICE_MESSAGE; 109 109 static GEOSMessageHandler ERROR_MESSAGE; 110 static GEOSMemoryAllocator GEOS_MALLOC; 111 static GEOSMemoryDeallocator GEOS_FREE; 110 112 static int WKBOutputDims = 2; 111 113 static int WKBByteOrder = getMachineByteOrder(); 112 114 115 #include <exception> // for std::bad_alloc 116 #include <new> 117 #include <cstdlib> // for malloc() and free() 118 #include <cstdio> // for printf() 119 120 // Visual C++ fix of operator new 121 122 void* operator new (size_t size) throw (std::bad_alloc) 123 { 124 void *p; 125 if(GEOS_MALLOC) { 126 p=GEOS_MALLOC(size); 127 printf("geos "); 128 } 129 else { 130 p=malloc(size); 131 printf("std "); 132 } 133 if (p==0) { // did malloc succeed? 134 throw std::bad_alloc(); // ANSI/ISO compliant behavior 135 } 136 printf("alloc!\n"); 137 return p; 138 } 139 140 void operator delete (void *p) throw() 141 { 142 if(GEOS_FREE) { 143 GEOS_FREE(p); 144 } 145 else { 146 free(p); 147 } 148 } 149 150 151 113 152 extern "C" { 114 153 115 154 void 116 155 initGEOS (GEOSMessageHandler nf, GEOSMessageHandler ef) 156 117 157 { 118 158 NOTICE_MESSAGE = nf; 119 159 ERROR_MESSAGE = ef; 120 160 } 121 161 122 162 void 163 initGEOSMemory(GEOSMemoryAllocator ma, GEOSMemoryDeallocator da) 164 { 165 GEOS_FREE = da; 166 GEOS_MALLOC = ma; 167 } 168 169 void 123 170 finishGEOS () 124 171 { 125 172 // Nothing to do
