Added fedex_plus/express cleanup functions.
* A lot of memory allocated in EXPRESSinitialize was not cleaned up. Added EXPRESScleanup function and subfunctions to clean up that memory.
This commit is contained in:
1 parent
bd320c403d
commit
f5d0cc59aa
20 files changed
+180
-4
No files matched your search
@@ -106,6 +106,7 @@ GLOBAL SCL_EXPRESS_EXPORT char DICT_type; /**< set as a side-effect of DICT loo
|
||||
/***********************/
|
||||
|
||||
extern SCL_EXPRESS_EXPORT void DICTinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void DICTcleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT int DICTdefine PROTO( ( Dictionary, char *, Generic, Symbol *, char ) );
|
||||
extern SCL_EXPRESS_EXPORT int DICT_define PROTO( ( Dictionary, char *, Generic, Symbol *, char ) );
|
||||
extern SCL_EXPRESS_EXPORT void DICTundefine PROTO( ( Dictionary, char * ) );
|
||||
|
||||
@@ -184,10 +184,12 @@ static_inline void ERRORflush_messages( void ) {
|
||||
|
||||
extern SCL_EXPRESS_EXPORT void ERRORinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORinitialize_after_LIST PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORcleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORnospace PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORabort PROTO( ( int ) );
|
||||
extern SCL_EXPRESS_EXPORT Error ERRORcreate PROTO( ( char *, Severity ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORreport PROTO( ( Error, ... ) );
|
||||
extern SCL_EXPRESS_EXPORT void ERRORdestroy PROTO( ( Error ) );
|
||||
|
||||
struct Symbol_; /* mention Symbol to avoid warning on following line */
|
||||
extern SCL_EXPRESS_EXPORT void ERRORreport_with_symbol PROTO( ( Error, struct Symbol_ *, ... ) );
|
||||
|
||||
@@ -270,6 +270,7 @@ extern SCL_EXPRESS_EXPORT Expression BIN_EXPcreate PROTO( ( Op_Code, Expressio
|
||||
extern SCL_EXPRESS_EXPORT Expression TERN_EXPcreate PROTO( ( Op_Code, Expression, Expression, Expression ) );
|
||||
extern SCL_EXPRESS_EXPORT Expression QUERYcreate PROTO( ( Symbol *, Expression ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPcleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT Type EXPtype PROTO( ( Expression, struct Scope_ * ) );
|
||||
extern SCL_EXPRESS_EXPORT int EXPget_integer_value PROTO( ( Expression ) );
|
||||
|
||||
|
||||
@@ -266,8 +266,10 @@ GLOBAL SCL_EXPRESS_EXPORT char * KW_XOR INITIALLY( "XOR" );
|
||||
/***********************/
|
||||
|
||||
extern SCL_EXPRESS_EXPORT Express EXPRESScreate PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPRESSdestroy PROTO( ( Express ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPRESSparse PROTO( ( Express, FILE *, char * ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPRESSinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPRESScleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void EXPRESSresolve PROTO( ( Express ) );
|
||||
extern SCL_EXPRESS_EXPORT char * EXPRESSversion PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT int EXPRESS_fail PROTO( ( Express ) );
|
||||
|
||||
@@ -135,6 +135,7 @@ GLOBAL SCL_EXPRESS_EXPORT Linked_List LINK__l; /* for LISTcreate_with macro
|
||||
/***********************/
|
||||
|
||||
extern SCL_EXPRESS_EXPORT void LISTinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void LISTcleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List LISTcreate PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List LISTcopy PROTO( ( Linked_List ) );
|
||||
extern SCL_EXPRESS_EXPORT Generic LISTadd_first PROTO( ( Linked_List, Generic ) );
|
||||
|
||||
@@ -108,6 +108,7 @@ GLOBAL SCL_EXPRESS_EXPORT struct Object * OBJ;
|
||||
/***********************/
|
||||
|
||||
extern SCL_EXPRESS_EXPORT void OBJinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void OBJcleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void OBJcreate PROTO( ( char, struct Symbol_ * ( * )( Generic ), char *, int ) );
|
||||
extern SCL_EXPRESS_EXPORT Symbol * UNK_get_symbol PROTO( ( Generic x ) );
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ GLOBAL SCL_EXPRESS_EXPORT Error ERROR_ambiguous_group INITIALLY( ERROR_
|
||||
/***********************/
|
||||
|
||||
extern SCL_EXPRESS_EXPORT void RESOLVEinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void RESOLVEcleanup PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void SCOPEresolve_expressions_statements PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT void SCOPEresolve_subsupers PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT void SCOPEresolve_types PROTO( ( Scope ) );
|
||||
|
||||
@@ -155,6 +155,7 @@ extern SCL_EXPRESS_EXPORT Generic SCHEMAfind PROTO( ( Schema, char * name, int
|
||||
extern SCL_EXPRESS_EXPORT Scope SCOPEcreate PROTO( ( char ) );
|
||||
extern SCL_EXPRESS_EXPORT Scope SCOPEcreate_tiny PROTO( ( char ) );
|
||||
extern SCL_EXPRESS_EXPORT Scope SCOPEcreate_nostab PROTO( ( char ) );
|
||||
extern SCL_EXPRESS_EXPORT void SCOPEdestroy PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List SCHEMAget_entities_use PROTO( ( Scope ) );
|
||||
extern SCL_EXPRESS_EXPORT Linked_List SCHEMAget_entities_ref PROTO( ( Scope ) );
|
||||
|
||||
|
||||
@@ -304,6 +304,7 @@ extern SCL_EXPRESS_EXPORT Type TYPEcreate_name PROTO( ( struct Symbol_ * ) );
|
||||
extern SCL_EXPRESS_EXPORT Type TYPEcreate_nostab PROTO( ( struct Symbol_ *, Scope, char ) );
|
||||
extern SCL_EXPRESS_EXPORT TypeBody TYPEBODYcreate PROTO( ( enum type_enum ) );
|
||||
extern SCL_EXPRESS_EXPORT void TYPEinitialize PROTO( ( void ) );
|
||||
extern SCL_EXPRESS_EXPORT void TYPEcleanup PROTO( ( void ) );
|
||||
|
||||
extern SCL_EXPRESS_EXPORT bool TYPEinherits_from PROTO( ( Type, enum type_enum ) );
|
||||
extern SCL_EXPRESS_EXPORT Type TYPEget_nonaggregate_base_type PROTO( ( Type ) );
|
||||
|
||||
@@ -63,6 +63,12 @@ void DICTinitialize( void ) {
|
||||
"Redeclaration of %s. Previous declaration was on line %d in file %s.", SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
/** Clean up the Dictionary module */
|
||||
void DICTcleanup( void ) {
|
||||
ERRORdestroy( ERROR_duplicate_decl );
|
||||
ERRORdestroy( ERROR_duplicate_decl_diff_file );
|
||||
}
|
||||
|
||||
/** \def DICTcreate
|
||||
** \param size - estimated (initial) max # of entries
|
||||
** \return a new dictionary of the specified size
|
||||
|
||||
@@ -124,6 +124,14 @@ void ERRORinitialize( void ) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Clean up the Error module */
|
||||
void ERRORcleanup( void ) {
|
||||
ERRORdestroy( ERROR_subordinate_failed );
|
||||
ERRORdestroy( ERROR_syntax_expecting );
|
||||
|
||||
scl_free( ERROR_string_base );
|
||||
}
|
||||
|
||||
/** Need the LIST routines to complete ERROR initialization */
|
||||
void ERRORinitialize_after_LIST( void ) {
|
||||
ERRORwarnings = LISTcreate();
|
||||
@@ -418,6 +426,10 @@ Error ERRORcreate( char * message, Severity severity ) {
|
||||
return n;
|
||||
}
|
||||
|
||||
void ERRORdestroy( Error * error ) {
|
||||
scl_free( error );
|
||||
}
|
||||
|
||||
/** \fn ERRORbuffer_messages
|
||||
** \param flag - to buffer or not to buffer
|
||||
** Selects buffering of error messages
|
||||
|
||||
@@ -218,6 +218,20 @@ void EXPinitialize( void ) {
|
||||
EXPop_init();
|
||||
}
|
||||
|
||||
void EXPcleanup( void ) {
|
||||
ERRORdestroy( ERROR_integer_expression_expected );
|
||||
ERRORdestroy( ERROR_internal_unrecognized_op_in_EXPresolve );
|
||||
ERRORdestroy( ERROR_attribute_reference_on_aggregate );
|
||||
ERRORdestroy( ERROR_attribute_ref_from_nonentity );
|
||||
ERRORdestroy( ERROR_indexing_illegal );
|
||||
ERRORdestroy( ERROR_warn_indexing_mixed );
|
||||
ERRORdestroy( ERROR_enum_no_such_item );
|
||||
ERRORdestroy( ERROR_group_ref_no_such_entity );
|
||||
ERRORdestroy( ERROR_group_ref_unexpected_type );
|
||||
ERRORdestroy( ERROR_implicit_downcast );
|
||||
ERRORdestroy( ERROR_ambig_implicit_downcast );
|
||||
}
|
||||
|
||||
/**
|
||||
* \param s_id the search id, a parameter to avoid colliding with ENTITYfind...
|
||||
* there will be no ambiguities, since we're looking at (and marking)
|
||||
|
||||
@@ -143,6 +143,15 @@ Express EXPRESScreate() {
|
||||
return model;
|
||||
}
|
||||
|
||||
void EXPRESSdestroy( Express model ) {
|
||||
if ( model->u.express->basename )
|
||||
scl_free( model->u.express->basename );
|
||||
if ( model->u.express->filename )
|
||||
scl_free( model->u.express->filename );
|
||||
scl_free( model->u.express );
|
||||
SCOPEdestroy( model );
|
||||
}
|
||||
|
||||
#define MAX_SCHEMA_FILENAME_SIZE 256
|
||||
typedef struct Dir {
|
||||
char full[MAX_SCHEMA_FILENAME_SIZE];
|
||||
@@ -221,6 +230,13 @@ static void EXPRESS_PATHinit() {
|
||||
}
|
||||
}
|
||||
|
||||
static void EXPRESS_PATHfree( void ) {
|
||||
LISTdo( EXPRESS_path, dir, Dir * )
|
||||
scl_free( dir );
|
||||
LISTod
|
||||
LISTfree( EXPRESS_path );
|
||||
}
|
||||
|
||||
/** inform object system about bit representation for handling pass diagnostics */
|
||||
void PASSinitialize() {
|
||||
OBJcreate( OBJ_PASS, UNK_get_symbol, "pass", OBJ_PASS_BITS );
|
||||
@@ -348,6 +364,30 @@ void EXPRESSinitialize( void ) {
|
||||
EXPRESS_PATHinit(); /* note, must follow defn of errors it needs! */
|
||||
}
|
||||
|
||||
/** Clean up the EXPRESS package. */
|
||||
void EXPRESScleanup( void ) {
|
||||
EXPRESS_PATHfree();
|
||||
|
||||
ERRORdestroy( ERROR_bail_out );
|
||||
ERRORdestroy( ERROR_syntax );
|
||||
ERRORdestroy( ERROR_ref_nonexistent );
|
||||
ERRORdestroy( ERROR_tilde_expansion_failed );
|
||||
ERRORdestroy( ERROR_schema_not_in_own_schema_file );
|
||||
ERRORdestroy( ERROR_unlabelled_param_type );
|
||||
ERRORdestroy( ERROR_file_unreadable );
|
||||
ERRORdestroy( ERROR_file_unwriteable );
|
||||
ERRORdestroy( ERROR_warn_unsupported_lang_feat );
|
||||
|
||||
DICTcleanup();
|
||||
OBJcleanup();
|
||||
ERRORcleanup();
|
||||
RESOLVEcleanup();
|
||||
TYPEcleanup();
|
||||
EXPcleanup();
|
||||
SCANcleanup();
|
||||
LISTcleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
** \param file - Express source file to parse
|
||||
** \return resulting Working Form model
|
||||
|
||||
+18
-4
@@ -139,6 +139,7 @@ int main( int argc, char ** argv ) {
|
||||
char * cp;
|
||||
int no_warnings = 1;
|
||||
int resolve = 1;
|
||||
int result;
|
||||
|
||||
bool buffer_messages = false;
|
||||
char * filename = 0;
|
||||
@@ -269,6 +270,7 @@ int main( int argc, char ** argv ) {
|
||||
if( !filename ) {
|
||||
filename = argv[optind];
|
||||
if( !filename ) {
|
||||
EXPRESScleanup();
|
||||
if( no_need_to_work ) {
|
||||
return( 0 );
|
||||
} else {
|
||||
@@ -289,7 +291,10 @@ int main( int argc, char ** argv ) {
|
||||
model = EXPRESScreate();
|
||||
EXPRESSparse( model, ( FILE * )0, filename );
|
||||
if( ERRORoccurred ) {
|
||||
return( EXPRESS_fail( model ) );
|
||||
result = EXPRESS_fail( model );
|
||||
EXPRESScleanup();
|
||||
EXPRESSdestroy( model );
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef debugging
|
||||
@@ -302,7 +307,10 @@ int main( int argc, char ** argv ) {
|
||||
if( resolve ) {
|
||||
EXPRESSresolve( model );
|
||||
if( ERRORoccurred ) {
|
||||
return( EXPRESS_fail( model ) );
|
||||
result = EXPRESS_fail( model );
|
||||
EXPRESScleanup();
|
||||
EXPRESSdestroy( model );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,8 +319,14 @@ int main( int argc, char ** argv ) {
|
||||
}
|
||||
|
||||
if( ERRORoccurred ) {
|
||||
return( EXPRESS_fail( model ) );
|
||||
result = EXPRESS_fail( model );
|
||||
EXPRESScleanup();
|
||||
EXPRESSdestroy( model );
|
||||
return result;
|
||||
}
|
||||
|
||||
return( EXPRESS_succeed( model ) );
|
||||
result = EXPRESS_succeed( model );
|
||||
EXPRESScleanup();
|
||||
EXPRESSdestroy( model );
|
||||
return result;
|
||||
}
|
||||
@@ -277,6 +277,19 @@ SCANinitialize( void ) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Clean up the Scan module */
|
||||
void SCANcleanup( void ) {
|
||||
ERRORdestroy( ERROR_include_file );
|
||||
ERRORdestroy( ERROR_unmatched_close_comment );
|
||||
ERRORdestroy( ERROR_unmatched_open_comment );
|
||||
ERRORdestroy( ERROR_unterminated_string );
|
||||
ERRORdestroy( ERROR_encoded_string_bad_digit );
|
||||
ERRORdestroy( ERROR_encoded_string_bad_count );
|
||||
ERRORdestroy( ERROR_bad_identifier );
|
||||
ERRORdestroy( ERROR_unexpected_character );
|
||||
ERRORdestroy( ERROR_nonascii_char );
|
||||
}
|
||||
|
||||
int
|
||||
SCANprocess_real_literal( void ) {
|
||||
sscanf( yytext, "%lf", &( yylval.rVal ) );
|
||||
|
||||
@@ -35,6 +35,10 @@ LISTinitialize( void ) {
|
||||
|
||||
}
|
||||
|
||||
void LISTcleanup( void ) {
|
||||
ERRORdestroy( ERROR_empty_list );
|
||||
}
|
||||
|
||||
Linked_List
|
||||
LISTcreate() {
|
||||
Linked_List list = LIST_new();
|
||||
|
||||
@@ -44,6 +44,11 @@ void OBJinitialize() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Clean up the Object module */
|
||||
void OBJcleanup() {
|
||||
scl_free( OBJ );
|
||||
}
|
||||
|
||||
void OBJcreate( char type, struct Symbol_ * ( *get_symbol )( Generic ), char * printable_type, int bits ) {
|
||||
unsigned index = ( unsigned )type;
|
||||
OBJ[index].get_symbol = get_symbol;
|
||||
|
||||
@@ -239,6 +239,53 @@ void RESOLVEinitialize( void ) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Clean up the Fed-X second pass */
|
||||
void RESOLVEcleanup( void ) {
|
||||
ERRORdestroy( ERROR_undefined );
|
||||
ERRORdestroy( ERROR_undefined_attribute );
|
||||
ERRORdestroy( ERROR_undefined_type );
|
||||
ERRORdestroy( ERROR_undefined_schema );
|
||||
ERRORdestroy( ERROR_unknown_attr_in_entity );
|
||||
ERRORdestroy( ERROR_unknown_subtype );
|
||||
ERRORdestroy( ERROR_unknown_supertype );
|
||||
ERRORdestroy( ERROR_circular_reference );
|
||||
ERRORdestroy( ERROR_subsuper_loop );
|
||||
ERRORdestroy( ERROR_subsuper_continuation );
|
||||
ERRORdestroy( ERROR_select_loop );
|
||||
ERRORdestroy( ERROR_select_continuation );
|
||||
ERRORdestroy( ERROR_supertype_resolve );
|
||||
ERRORdestroy( ERROR_subtype_resolve );
|
||||
ERRORdestroy( ERROR_not_a_type );
|
||||
ERRORdestroy( ERROR_funcall_not_a_function );
|
||||
ERRORdestroy( ERROR_undefined_func );
|
||||
ERRORdestroy( ERROR_expected_proc );
|
||||
ERRORdestroy( ERROR_no_such_procedure );
|
||||
ERRORdestroy( ERROR_wrong_arg_count );
|
||||
ERRORdestroy( ERROR_query_requires_aggregate );
|
||||
ERRORdestroy( ERROR_self_is_unknown );
|
||||
ERRORdestroy( ERROR_inverse_bad_entity );
|
||||
ERRORdestroy( ERROR_inverse_bad_attribute );
|
||||
ERRORdestroy( ERROR_missing_supertype );
|
||||
ERRORdestroy( ERROR_type_is_entity );
|
||||
ERRORdestroy( ERROR_ambiguous_attribute );
|
||||
ERRORdestroy( ERROR_ambiguous_group );
|
||||
ERRORdestroy( ERROR_overloaded_attribute );
|
||||
ERRORdestroy( ERROR_redecl_no_such_attribute );
|
||||
ERRORdestroy( ERROR_redecl_no_such_supertype );
|
||||
ERRORdestroy( ERROR_missing_self );
|
||||
|
||||
#if 0
|
||||
ERRORdestroy( ERROR_undefined_object );
|
||||
ERRORdestroy( ERROR_undefined_entity );
|
||||
ERRORdestroy( ERROR_inappropriate_use );
|
||||
ERRORdestroy( ERROR_overshadowed_reference );
|
||||
ERRORdestroy( ERROR_overloaded_reference );
|
||||
ERRORdestroy( ERROR_missing_subtype );
|
||||
ERRORdestroy( ERROR_shadow_decl );
|
||||
ERRORdestroy( ERROR_group_reference_syntax );
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
** Retrieve the aggregate type from the underlying types of the select type t_select
|
||||
** \param t_select the select type to retrieve the aggregate type from
|
||||
|
||||
@@ -84,6 +84,10 @@ Scope SCOPEcreate_tiny( char type ) {
|
||||
return d;
|
||||
}
|
||||
|
||||
void SCOPEdestroy( Scope scope ) {
|
||||
SCOPE_destroy( scope );
|
||||
}
|
||||
|
||||
/**
|
||||
* create a scope without a symbol table
|
||||
* used for simple types
|
||||
|
||||
@@ -385,6 +385,12 @@ void TYPEinitialize() {
|
||||
ERRORcreate( "Undefined type tag %s", SEVERITY_ERROR );
|
||||
}
|
||||
|
||||
/** Clean up the Type module */
|
||||
void TYPEcleanup( void ) {
|
||||
ERRORdestroy( ERROR_corrupted_type );
|
||||
ERRORdestroy( ERROR_undefined_tag );
|
||||
}
|
||||
|
||||
/**
|
||||
* \param t type to examine
|
||||
* \return the base type of the aggregate type
|
||||
|
||||
Reference in new issue
Block a user