Skip to content

Commit 3c785b4

Browse files
committed
move all allocator setup to new memory.c (initially just for tests)
1 parent 7e192a4 commit 3c785b4

13 files changed

Lines changed: 109 additions & 22 deletions

File tree

include/express/memory.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef __MEMORY_H
2+
#define __MEMORY_H
3+
4+
void MEMinit();
5+
6+
#endif // __MEMORY_H

src/express/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ set(EXPRESS_SOURCES
7878
dict.c
7979
hash.c
8080
alloc.c
81+
memory.c
8182
object.c
8283
express.c
8384
ordered_attrs.cc

src/express/caseitem.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <sc_memmgr.h>
3333
#include "express/caseitem.h"
3434

35-
struct freelist_head CASE_IT_fl;
3635

3736
/** Initialize the Case Item module. */
3837
void

src/express/entity.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
#include "express/express.h"
119119
#include "express/object.h"
120120

121-
struct freelist_head ENTITY_fl;
122121
int ENTITY_MARK = 0;
123122

124123
/** returns true if variable is declared (or redeclared) directly by entity */

src/express/error.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ int malloc_debug_resolve = 0;
9090
int debug = 0;
9191

9292
struct Linked_List_ * ERRORwarnings;
93-
struct freelist_head ERROR_OPT_fl;
9493

9594
void ( *ERRORusage_function )( void );
9695

src/express/expr.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ Error ERROR_integer_expression_expected = ERROR_none;
9090
Error ERROR_implicit_downcast = ERROR_none;
9191
Error ERROR_ambig_implicit_downcast = ERROR_none;
9292

93-
struct freelist_head EXP_fl;
94-
struct freelist_head OP_fl;
95-
struct freelist_head QUERY_fl;
96-
struct freelist_head QUAL_ATTR_fl;
97-
9893
void EXPop_init();
9994
static Error ERROR_internal_unrecognized_op_in_EXPresolve;
10095
/* following two could probably be combined */

src/express/hash.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@
111111
#include <stdlib.h>
112112
#include "express/hash.h"
113113

114-
struct freelist_head HASH_Table_fl;
115-
struct freelist_head HASH_Element_fl;
116-
117114
/*
118115
** Internal routines
119116
*/

src/express/linklist.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include "express/linklist.h"
2626

2727
Error ERROR_empty_list = ERROR_none;
28-
struct freelist_head LINK_fl;
29-
struct freelist_head LIST_fl;
3028

3129
void LISTinitialize( void ) {
3230
ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 );

src/express/memory.c

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#include "express/memory.h"
2+
3+
#include "express/alloc.h"
4+
5+
#include "express/hash.h"
6+
#include "express/symbol.h"
7+
#include "express/schema.h"
8+
#include "express/type.h"
9+
10+
struct freelist_head HASH_Table_fl;
11+
struct freelist_head HASH_Element_fl;
12+
13+
struct freelist_head LINK_fl;
14+
struct freelist_head LIST_fl;
15+
16+
struct freelist_head ERROR_OPT_fl;
17+
18+
struct freelist_head SYMBOL_fl;
19+
20+
struct freelist_head SCOPE_fl;
21+
struct freelist_head SCHEMA_fl;
22+
23+
struct freelist_head TYPEHEAD_fl;
24+
struct freelist_head TYPEBODY_fl;
25+
26+
struct freelist_head VAR_fl;
27+
28+
struct freelist_head FUNC_fl;
29+
struct freelist_head RULE_fl;
30+
struct freelist_head PROC_fl;
31+
struct freelist_head WHERE_fl;
32+
33+
struct freelist_head ENTITY_fl;
34+
35+
struct freelist_head CASE_IT_fl;
36+
37+
struct freelist_head EXP_fl;
38+
struct freelist_head OP_fl;
39+
struct freelist_head QUERY_fl;
40+
struct freelist_head QUAL_ATTR_fl;
41+
42+
struct freelist_head STMT_fl;
43+
struct freelist_head ALIAS_fl;
44+
struct freelist_head ASSIGN_fl;
45+
struct freelist_head CASE_fl;
46+
struct freelist_head COMP_STMT_fl;
47+
struct freelist_head COND_fl;
48+
struct freelist_head LOOP_fl;
49+
struct freelist_head PCALL_fl;
50+
struct freelist_head RET_fl;
51+
struct freelist_head INCR_fl;
52+
53+
void MEMinit() {
54+
_ALLOCinitialize();
55+
56+
ALLOCinitialize( &HASH_Table_fl, sizeof( struct Hash_Table_ ), 50, 50 );
57+
ALLOCinitialize( &HASH_Element_fl, sizeof( struct Element_ ), 500, 100 );
58+
59+
ALLOCinitialize( &LINK_fl, sizeof( struct Link_ ), 500, 100 );
60+
ALLOCinitialize( &LIST_fl, sizeof( struct Linked_List_ ), 100, 50 );
61+
62+
ALLOCinitialize( &ERROR_OPT_fl, sizeof( struct Error_Warning_ ), 5, 5 );
63+
64+
ALLOCinitialize( &SYMBOL_fl, sizeof( struct Symbol_ ), 100, 100 );
65+
66+
ALLOCinitialize( &SCOPE_fl, sizeof( struct Scope_ ), 100, 50 );
67+
68+
ALLOCinitialize( &TYPEHEAD_fl, sizeof( struct TypeHead_ ), 500, 100 );
69+
ALLOCinitialize( &TYPEBODY_fl, sizeof( struct TypeBody_ ), 200, 100 );
70+
71+
ALLOCinitialize( &VAR_fl, sizeof( struct Variable_ ), 100, 50 );
72+
73+
ALLOCinitialize( &FUNC_fl, sizeof( struct Function_ ), 100, 50 );
74+
ALLOCinitialize( &RULE_fl, sizeof( struct Rule_ ), 100, 50 );
75+
ALLOCinitialize( &PROC_fl, sizeof( struct Procedure_ ), 100, 50 );
76+
ALLOCinitialize( &WHERE_fl, sizeof( struct Where_ ), 100, 50 );
77+
78+
ALLOCinitialize( &ENTITY_fl, sizeof( struct Entity_ ), 500, 100 );
79+
80+
ALLOCinitialize( &SCHEMA_fl, sizeof( struct Schema_ ), 40, 20 );
81+
82+
ALLOCinitialize( &CASE_IT_fl, sizeof( struct Case_Item_ ), 500, 100 );
83+
84+
ALLOCinitialize( &EXP_fl, sizeof( struct Expression_ ), 500, 200 );
85+
ALLOCinitialize( &OP_fl, sizeof( struct Op_Subexpression ), 500, 100 );
86+
ALLOCinitialize( &QUERY_fl, sizeof( struct Query_ ), 50, 10 );
87+
ALLOCinitialize( &QUAL_ATTR_fl, sizeof( struct Query_ ), 20, 10 );
88+
89+
ALLOCinitialize( &STMT_fl, sizeof( struct Statement_ ), 500, 100 );
90+
91+
ALLOCinitialize( &ALIAS_fl, sizeof( struct Alias_ ), 10, 10 );
92+
ALLOCinitialize( &ASSIGN_fl, sizeof( struct Assignment_ ), 100, 30 );
93+
ALLOCinitialize( &CASE_fl, sizeof( struct Case_Statement_ ), 100, 30 );
94+
ALLOCinitialize( &COMP_STMT_fl, sizeof( struct Compound_Statement_ ), 100, 30 );
95+
ALLOCinitialize( &COND_fl, sizeof( struct Conditional_ ), 100, 30 );
96+
ALLOCinitialize( &LOOP_fl, sizeof( struct Loop_ ), 100, 30 );
97+
ALLOCinitialize( &PCALL_fl, sizeof( struct Procedure_Call_ ), 100, 30 );
98+
ALLOCinitialize( &RET_fl, sizeof( struct Return_Statement_ ), 100, 30 );
99+
ALLOCinitialize( &INCR_fl, sizeof( struct Increment_ ), 100, 30 );
100+
101+
}
102+

src/express/schema.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
#include "express/resolve.h"
5353

5454
struct freelist_head REN_fl;
55-
struct freelist_head SCOPE_fl;
56-
struct freelist_head SCHEMA_fl;
5755

5856
int __SCOPE_search_id = 0;
5957

0 commit comments

Comments
 (0)