Skip to content

Commit 46d7a41

Browse files
committed
Need to use a static function for pools instead of a static object to avoid problems with initialisation order
git-svn-id: svn+ssh://svn.gecode.org/srv/gecode/svn/gecode/trunk@16768 64335634-5103-0410-b293-fc3d331e086d
1 parent 4e99334 commit 46d7a41

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

gecode/kernel/memory/region.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ namespace Gecode {
8080
m.release();
8181
}
8282

83-
Region::Pool Region::pool;
83+
Region::Pool& Region::pool(void) {
84+
static Region::Pool _p;
85+
return _p;
86+
}
8487

8588
void*
8689
Region::heap_alloc(size_t s) {

gecode/kernel/memory/region.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace Gecode {
9292
~Pool(void);
9393
};
9494
/// Just use a single static pool for heap chunks
95-
GECODE_KERNEL_EXPORT static Pool pool;
95+
GECODE_KERNEL_EXPORT Pool& pool();
9696
/// Heap information data structure
9797
class HeapInfo {
9898
public:
@@ -348,7 +348,7 @@ namespace Gecode {
348348

349349
forceinline
350350
Region::Region(void)
351-
: chunk(pool.chunk()), hi(0) {}
351+
: chunk(pool().chunk()), hi(0) {}
352352

353353
forceinline void
354354
Region::free(void) {
@@ -369,7 +369,7 @@ namespace Gecode {
369369

370370
forceinline
371371
Region::~Region(void) {
372-
pool.chunk(chunk);
372+
pool().chunk(chunk);
373373
if (hi != NULL)
374374
heap_free();
375375
}

0 commit comments

Comments
 (0)