Added use of scl_memmgr to fedex_plus application.

* Replaced malloc, calloc, realloc and free with scl_memmgr versions.
* Added scl_memmgr.h includes.
This commit is contained in:
davyw 2012-02-27 21:21:55 +01:00
parent 7ce8bcbefb
commit 4e0d73d001
19 changed files with 47 additions and 27 deletions

View file

@ -25,6 +25,7 @@ include_directories(
${SCL_SOURCE_DIR}/include
${SCL_SOURCE_DIR}/include/exppp
${SCL_SOURCE_DIR}/include/express
${SCL_SOURCE_DIR}/src/base
)
IF(MSVC OR BORLAND)
@ -33,12 +34,13 @@ set(fedex_plus_EXTRA_SOURCES
)
add_definitions( -DSCL_EXPRESS_DLL_IMPORTS )
add_definitions( -DSCL_EXPPP_DLL_IMPORTS )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
ENDIF()
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
add_definitions( -DYYDEBUG ) #-Ddebugging )
ENDIF()
SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES} ${fedex_plus_EXTRA_SOURCES}" "libexppp express")
SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES} ${fedex_plus_EXTRA_SOURCES}" "libexppp express base")
add_dependencies( fedex_plus version_string )

View file

@ -25,6 +25,7 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7.
/* this is used to add new dictionary calls */
/* #define NEWDICT */
#include <scl_memmgr.h>
#include <stdlib.h>
#include "classes.h"
@ -446,7 +447,7 @@ char * generate_attribute_name( Variable a, char * out ) {
p++;
}
*q = '\0';
free( temp );
scl_free( temp );
return out;
}
@ -503,7 +504,7 @@ char * generate_dict_attr_name( Variable a, char * out ) {
}
}
free( temp );
scl_free( temp );
return out;
}
@ -595,7 +596,7 @@ char * TYPEget_express_type( const Type t ) {
/* this will declare extra memory when aggregate is > 1D */
permval = ( char * )malloc( strlen( retval ) * sizeof( char ) + 1 );
permval = ( char * )scl_malloc( strlen( retval ) * sizeof( char ) + 1 );
strcpy( permval, retval );
return permval;
@ -2018,7 +2019,7 @@ void ENTITYincode_print( Entity entity, FILE * file, Schema schema ) {
format_for_std_stringout( file, tmp );
fprintf( file, "\n str.append( \")\" );\n" );
fprintf( file, " %s::%s%s->AddSupertype_Stmt( str );", schema_name, ENT_PREFIX, entity_name );
free( tmp );
scl_free( tmp );
} else {
fprintf( file, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n",
schema_name, ENT_PREFIX, entity_name );
@ -2029,7 +2030,7 @@ void ENTITYincode_print( Entity entity, FILE * file, Schema schema ) {
tmp = SUBTYPEto_string( entity->u.entity->subtype_expression );
format_for_std_stringout( file, tmp );
fprintf( file, "\n str.append( \")\" );\n" );
free( tmp );
scl_free( tmp );
fprintf( file, " %s::%s%s->AddSupertype_Stmt( str );", schema_name, ENT_PREFIX, entity_name );
}
}
@ -2181,15 +2182,15 @@ void ENTITYincode_print( Entity entity, FILE * file, Schema schema ) {
if( VARis_derived( v ) && v->initializer ) {
tmp = EXPRto_string( v->initializer );
tmp2 = ( char * )malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) );
tmp2 = ( char * )scl_malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) );
fprintf( file, " %s::%s%d%s%s->initializer_(\"%s\");\n",
schema_name, ATTR_PREFIX, attr_count,
( VARis_derived( v ) ? "D" :
( VARis_type_shifter( v ) ? "R" :
( VARget_inverse( v ) ? "I" : "" ) ) ),
attrnm, format_for_stringout( tmp, tmp2 ) );
free( tmp );
free( tmp2 );
scl_free( tmp );
scl_free( tmp2 );
}
if( VARget_inverse( v ) ) {
fprintf( file, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n",
@ -2403,11 +2404,11 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
if( whereRule_formatted_size == 0 ) {
whereRule_formatted_size = 3 * BUFSIZ;
whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size );
whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size );
} else if( ( strlen( whereRule ) + 300 ) > whereRule_formatted_size ) {
free( whereRule_formatted );
scl_free( whereRule_formatted );
whereRule_formatted_size = strlen( whereRule ) + BUFSIZ;
whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size );
whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size );
}
whereRule_formatted[0] = '\0';
if( w->label ) {
@ -2481,7 +2482,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
fprintf( files->create, " %s::%s%s->_where_rules->Append(wr);\n",
SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) );
free( whereRule );
scl_free( whereRule );
ptr2 = whereRule = 0;
LISTod
}
@ -2494,7 +2495,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) );
if( whereRule_formatted_size == 0 ) {
uniqRule_formatted = ( char * )malloc( sizeof( char ) * 2 * BUFSIZ );
uniqRule_formatted = ( char * )scl_malloc( sizeof( char ) * 2 * BUFSIZ );
whereRule_formatted = uniqRule_formatted;
} else {
uniqRule_formatted = whereRule_formatted;
@ -2534,7 +2535,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap
}
if( whereRule_formatted_size > 0 ) {
free( whereRule_formatted );
scl_free( whereRule_formatted );
}
n = ENTITYget_classname( entity );
@ -2775,7 +2776,7 @@ void Type_Description( const Type, char * );
* return it in static buffer
*/
char * TypeDescription( const Type t ) {
static char buf[4000];
static char buf[5000];
buf[0] = '\0';
@ -3467,11 +3468,11 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema ) {
if( whereRule_formatted_size == 0 ) {
whereRule_formatted_size = 3 * BUFSIZ;
whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size );
whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size );
} else if( ( strlen( whereRule ) + 300 ) > whereRule_formatted_size ) {
free( whereRule_formatted );
scl_free( whereRule_formatted );
whereRule_formatted_size = strlen( whereRule ) + BUFSIZ;
whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size );
whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size );
}
whereRule_formatted[0] = '\0';
if( w->label ) {
@ -3529,10 +3530,10 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema ) {
fprintf( create, " %s->_where_rules->Append(wr);\n",
TYPEtd_name( type ) );
free( whereRule );
scl_free( whereRule );
ptr2 = whereRule = 0;
LISTod
free( whereRule_formatted );
scl_free( whereRule_formatted );
}
}

View file

@ -1,4 +1,5 @@
#define CLASSES_MISC_C
#include <scl_memmgr.h>
#include <stdlib.h>
#include "classes.h"
/*******************************************************************
@ -674,7 +675,7 @@ ENTITYput_superclass( Entity entity ) {
LISTod;
}
tag = ( EntityTag ) malloc( sizeof( struct EntityTag_ ) );
tag = ( EntityTag ) scl_malloc( sizeof( struct EntityTag_ ) );
tag -> superclass = super;
TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag );
return super;
@ -742,10 +743,10 @@ VARis_type_shifter( Variable a ) {
temp = EXPRto_string( VARget_name( a ) );
if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) {
/* a is a type shifter */
free( temp );
scl_free( temp );
return a;
}
free( temp );
scl_free( temp );
return 0;
}

View file

@ -3,6 +3,7 @@
#include <string.h>
#include "complexSupport.h"
#include <scl_memmgr.h>
/*******************************************************************
** FedEx parser output module for generating C++ class definitions

View file

@ -12,6 +12,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
void ComplexCollect::insert( ComplexList * c )
/*

View file

@ -11,6 +11,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
ComplexList::~ComplexList()
/*

View file

@ -14,6 +14,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
int EntList::siblings()
/*

View file

@ -12,6 +12,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
EntNode::EntNode( char * namelist[] )
/*

View file

@ -12,6 +12,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
// Local function prototypes:
static void initEnts( Express );

View file

@ -72,6 +72,7 @@
* Added * to typedefs. Replaced warning kludges with ERRORoption.
*/
#include <scl_memmgr.h>
#include <stdlib.h>
#include <stdio.h>
#include "../express/express.h"

View file

@ -14,6 +14,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
MatchType AndOrList::matchORs( EntNode * ents )
/*

View file

@ -13,6 +13,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
MultList::~MultList()
/*

View file

@ -31,6 +31,7 @@
* Date: 04/09/97 *
*****************************************************************************/
#include <scl_memmgr.h>
#include <stdlib.h>
#include "classes.h"
@ -184,7 +185,7 @@ static void initializeMarks( Express express )
DICTdo_type_init( express->symbol_table, &de_sch, OBJ_SCHEMA );
while( ( schema = ( Scope )DICTdo( &de_sch ) ) != 0 ) {
schema->search_id = UNPROCESSED;
schema->clientData = ( int * )malloc( sizeof( int ) );
schema->clientData = ( int * )scl_malloc( sizeof( int ) );
*( int * )schema->clientData = 0;
SCOPEdo_entities( schema, ent, de_ent )
ent->search_id = NOTKNOWN;

View file

@ -11,6 +11,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
MatchType SimpleList::matchNonORs( EntNode * ents )
/*

View file

@ -11,6 +11,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
int OrList::hit( const char * nm )
/*

View file

@ -8,6 +8,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
// Local function prototypes:
static char * joinText( JoinType, char * );

View file

@ -22,6 +22,7 @@ extern int multiple_inheritance;
******** The functions in this file generate C++ code for representing
******** EXPRESS SELECT types.
**************************************************************************/
#include <scl_memmgr.h>
#include <stdlib.h>
#include "classes.h"
@ -464,7 +465,7 @@ non_unique_types_string( const Type type ) {
non_unique_types_vector( type, tvec );
/* build type string from vector */
typestr = ( char * )malloc( BUFSIZ );
typestr = ( char * )scl_malloc( BUFSIZ );
typestr[0] = '\0';
strcat( typestr, ( char * )"(" );
for( i = 0; i <= tnumber; i++ ) {
@ -1946,7 +1947,7 @@ TYPEselect_print( Type t, FILES * files, Schema schema ) {
}
/* mark the type as being processed */
tag = ( SelectTag ) malloc( sizeof( struct SelectTag_ ) );
tag = ( SelectTag ) scl_malloc( sizeof( struct SelectTag_ ) );
tag -> started = 1;
tag -> complete = 0;
TYPEput_clientData( t, ( ClientData ) tag );

View file

@ -12,6 +12,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
// Local function prototypes:
static EntList * firstCandidate( EntList * );

View file

@ -11,6 +11,7 @@
*****************************************************************************/
#include "complexSupport.h"
#include <scl_memmgr.h>
// Local function prototypes:
static void writeheader( ostream &, int );