Skip to content

Commit a160cc9

Browse files
committed
fix stepcode#327 - statically initialize t_sdaiINTEGER etc
1 parent 1dfe76b commit a160cc9

2 files changed

Lines changed: 16 additions & 80 deletions

File tree

src/clstepcore/Registry.cc

Lines changed: 9 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
#include <Registry.h>
1414
#include "sc_memmgr.h"
1515

16-
const TypeDescriptor * t_sdaiINTEGER = NULL;
17-
const TypeDescriptor * t_sdaiREAL = NULL;
18-
const TypeDescriptor * t_sdaiNUMBER = NULL;
19-
const TypeDescriptor * t_sdaiSTRING = NULL;
20-
const TypeDescriptor * t_sdaiBINARY = NULL;
21-
const TypeDescriptor * t_sdaiBOOLEAN = NULL;
22-
const TypeDescriptor * t_sdaiLOGICAL = NULL;
16+
/* these may be shared between multiple Registry instances, so don't create/destroy in Registry ctor/dtor
17+
* Name, FundamentalType, Originating Schema, Description */
18+
const TypeDescriptor * const t_sdaiINTEGER = new TypeDescriptor( "INTEGER", sdaiINTEGER, 0, "INTEGER" );
19+
const TypeDescriptor * const t_sdaiREAL = new TypeDescriptor( "REAL", sdaiREAL, 0, "Real" );
20+
const TypeDescriptor * const t_sdaiNUMBER = new TypeDescriptor( "NUMBER", sdaiNUMBER, 0, "Number" );
21+
const TypeDescriptor * const t_sdaiSTRING = new TypeDescriptor( "STRING", sdaiSTRING, 0, "String" );
22+
const TypeDescriptor * const t_sdaiBINARY = new TypeDescriptor( "BINARY", sdaiBINARY, 0, "Binary" );
23+
const TypeDescriptor * const t_sdaiBOOLEAN = new TypeDescriptor( "BOOLEAN", sdaiBOOLEAN, 0, "Boolean" );
24+
const TypeDescriptor * const t_sdaiLOGICAL = new TypeDescriptor( "LOGICAL", sdaiLOGICAL, 0, "Logical" );
2325

2426
static int uniqueNames( const char *, const SchRename * );
2527

@@ -30,43 +32,6 @@ Registry::Registry( CF_init initFunct )
3032
active_schemas = SC_HASHcreate( 10 );
3133
active_types = SC_HASHcreate( 100 );
3234

33-
if( !t_sdaiINTEGER ) {
34-
t_sdaiINTEGER = new TypeDescriptor( "INTEGER", // Name
35-
sdaiINTEGER, // FundamentalType
36-
0, // Originating Schema
37-
"INTEGER" ); // Description;
38-
}
39-
if( !t_sdaiREAL ) {
40-
t_sdaiREAL = new TypeDescriptor( "REAL", sdaiREAL,
41-
0, // Originating Schema
42-
"Real" );
43-
}
44-
if( !t_sdaiSTRING ) {
45-
t_sdaiSTRING = new TypeDescriptor( "STRING", sdaiSTRING,
46-
0, // Originating Schema
47-
"String" );
48-
}
49-
if( !t_sdaiBINARY ) {
50-
t_sdaiBINARY = new TypeDescriptor( "BINARY", sdaiBINARY,
51-
0, // Originating Schema
52-
"Binary" );
53-
}
54-
if( !t_sdaiBOOLEAN ) {
55-
t_sdaiBOOLEAN = new TypeDescriptor( "BOOLEAN", sdaiBOOLEAN,
56-
0, // Originating Schema
57-
"Boolean" );
58-
}
59-
if( !t_sdaiLOGICAL ) {
60-
t_sdaiLOGICAL = new TypeDescriptor( "LOGICAL", sdaiLOGICAL,
61-
0, // Originating Schema
62-
"Logical" );
63-
}
64-
if( !t_sdaiNUMBER ) {
65-
t_sdaiNUMBER = new TypeDescriptor( "NUMBER", sdaiNUMBER,
66-
0, // Originating Schema
67-
"Number" );
68-
}
69-
7035
initFunct( *this );
7136
SC_HASHlistinit( active_types, &cur_type );
7237
SC_HASHlistinit( primordialSwamp, &cur_entity ); // initialize cur's
@@ -80,35 +45,6 @@ Registry::~Registry() {
8045
SC_HASHdestroy( active_schemas );
8146
SC_HASHdestroy( active_types );
8247
delete col;
83-
84-
if( t_sdaiINTEGER ) {
85-
delete t_sdaiINTEGER;
86-
t_sdaiINTEGER = NULL;
87-
}
88-
if( t_sdaiREAL ) {
89-
delete t_sdaiREAL;
90-
t_sdaiREAL = NULL;
91-
}
92-
if( t_sdaiSTRING ) {
93-
delete t_sdaiSTRING;
94-
t_sdaiSTRING = NULL;
95-
}
96-
if( t_sdaiBINARY ) {
97-
delete t_sdaiBINARY;
98-
t_sdaiBINARY = NULL;
99-
}
100-
if( t_sdaiBOOLEAN ) {
101-
delete t_sdaiBOOLEAN;
102-
t_sdaiBOOLEAN = NULL;
103-
}
104-
if( t_sdaiLOGICAL ) {
105-
delete t_sdaiLOGICAL;
106-
t_sdaiLOGICAL = NULL;
107-
}
108-
if( t_sdaiNUMBER ) {
109-
delete t_sdaiNUMBER;
110-
t_sdaiNUMBER = NULL;
111-
}
11248
}
11349

11450
void Registry::DeleteContents() {

src/clstepcore/Registry.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222

2323
// defined and created in Registry.cc
24-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiINTEGER;
25-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiREAL;
26-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiNUMBER;
27-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiSTRING;
28-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiBINARY;
29-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiBOOLEAN;
30-
extern SC_CORE_EXPORT const TypeDescriptor * t_sdaiLOGICAL;
24+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiINTEGER;
25+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiREAL;
26+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiNUMBER;
27+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiSTRING;
28+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBINARY;
29+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiBOOLEAN;
30+
extern SC_CORE_EXPORT const TypeDescriptor * const t_sdaiLOGICAL;
3131

3232
typedef struct Hash_Table * HashTable;
3333

0 commit comments

Comments
 (0)