23 */
24
25 // FORMS.CPP - Definitions for ADL Parser Generic & Utility Forms Classes
26 #include "adlc.hpp"
27
28 //------------------------------Static Initializers----------------------------
29 // allocate arena used by forms
30 Arena *Form::arena = Form::generate_arena(); // = Form::generate_arena();
31 Arena *Form::generate_arena() {
32 return (new Arena);
33 }
34
35 //------------------------------NameList---------------------------------------
36 // reserved user-defined string
37 const char *NameList::_signal = "$$SIGNAL$$";
38 const char *NameList::_signal2 = "$$SIGNAL2$$";
39 const char *NameList::_signal3 = "$$SIGNAL3$$";
40
41 // Constructor and Destructor
42 NameList::NameList() : _cur(0), _max(4), _iter(0), _justReset(true) {
43 _names = (const char**)malloc(_max*sizeof(char*));
44 }
45 NameList::~NameList() {
46 // The following free is a double-free, and crashes the program:
47 //free(_names); // not owner of strings
48 }
49
50 void NameList::addName(const char *name) {
51 if (_cur == _max) _names =(const char**)realloc(_names,(_max *=2)*sizeof(char*));
52 _names[_cur++] = name;
53 }
54
55 void NameList::add_signal() {
56 addName( _signal );
57 }
58 void NameList::clear() {
59 _cur = 0;
60 _iter = 0;
61 _justReset = true;
62 // _max = 4; Already allocated
63 }
|
23 */
24
25 // FORMS.CPP - Definitions for ADL Parser Generic & Utility Forms Classes
26 #include "adlc.hpp"
27
28 //------------------------------Static Initializers----------------------------
29 // allocate arena used by forms
30 Arena *Form::arena = Form::generate_arena(); // = Form::generate_arena();
31 Arena *Form::generate_arena() {
32 return (new Arena);
33 }
34
35 //------------------------------NameList---------------------------------------
36 // reserved user-defined string
37 const char *NameList::_signal = "$$SIGNAL$$";
38 const char *NameList::_signal2 = "$$SIGNAL2$$";
39 const char *NameList::_signal3 = "$$SIGNAL3$$";
40
41 // Constructor and Destructor
42 NameList::NameList() : _cur(0), _max(4), _iter(0), _justReset(true) {
43 _names = (const char**) AllocateHeap(_max*sizeof(char*));
44 }
45 NameList::~NameList() {
46 // The following free is a double-free, and crashes the program:
47 //free(_names); // not owner of strings
48 }
49
50 void NameList::addName(const char *name) {
51 if (_cur == _max) _names =(const char**)realloc(_names,(_max *=2)*sizeof(char*));
52 _names[_cur++] = name;
53 }
54
55 void NameList::add_signal() {
56 addName( _signal );
57 }
58 void NameList::clear() {
59 _cur = 0;
60 _iter = 0;
61 _justReset = true;
62 // _max = 4; Already allocated
63 }
|