Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added use of scl_memmgr to express library.
* Replaced malloc, calloc, realloc and free with scl_memmgr versions.
* Added scl_memmgr.h includes.
  • Loading branch information
davyw committed Feb 27, 2012
commit 4d6d249dadd80c72c51bcd6efa9f2714dc7a6984
4 changes: 3 additions & 1 deletion src/express/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ SET(EXPRESS_PRIVATE_HDRS
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${SCL_SOURCE_DIR}/src/base
)

add_definitions( -DFLEX )
Expand All @@ -80,9 +81,10 @@ endif()

if(BORLAND)
add_definitions( -D__STDC__ )
add_definitions( -DSCL_BASE_DLL_IMPORTS )
endif()

SCL_ADDLIB(express "${EXPRESS_SOURCES}" "")
SCL_ADDLIB(express "${EXPRESS_SOURCES}" "base")

if(APPLE)
set_target_properties(express PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
Expand Down
1 change: 1 addition & 0 deletions src/express/alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* prettied up interface to print_objects_when_running
*/

#include <scl_memmgr.h>
#define ALGORITHM_C
#include "express/alg.h"
#include "express/object.h"
Expand Down
1 change: 1 addition & 0 deletions src/express/caseitem.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* prettied up interface to print_objects_when_running
*/

#include <scl_memmgr.h>
#define CASE_ITEM_C
#include "express/caseitem.h"

Expand Down
1 change: 1 addition & 0 deletions src/express/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* Initial revision
*/

#include <scl_memmgr.h>
#define DICTIONARY_C
#include "express/dict.h"
#include "express/object.h"
Expand Down
1 change: 1 addition & 0 deletions src/express/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
*
*/

#include <scl_memmgr.h>
#define ENTITY_C
#include "express/entity.h"
#include "express/express.h"
Expand Down
5 changes: 3 additions & 2 deletions src/express/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*/

#include <scl_cf.h>
#include <scl_memmgr.h>
#include <stdlib.h>
#include <setjmp.h>
#ifdef HAVE_UNISTD_H
Expand Down Expand Up @@ -105,7 +106,7 @@ void ERRORinitialize( void ) {
ERROR_syntax_expecting =
ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT );

ERROR_string_base = ( char * )malloc( ERROR_MAX_SPACE );
ERROR_string_base = ( char * )scl_malloc( ERROR_MAX_SPACE );
ERROR_start_message_buffer();


Expand Down Expand Up @@ -410,7 +411,7 @@ void ERRORnospace() {
Error ERRORcreate( char * message, Severity severity ) {
Error n;

n = ( struct Error_ * )malloc( sizeof( struct Error_ ) );
n = ( struct Error_ * )scl_malloc( sizeof( struct Error_ ) );
n->message = message;
n->severity = severity;
n->enabled = true;
Expand Down
1 change: 1 addition & 0 deletions src/express/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
*/

#include <scl_cf.h>
#include <scl_memmgr.h>
#define EXPRESSION_C

#ifdef HAVE_UNISTD_H
Expand Down
9 changes: 5 additions & 4 deletions src/express/express.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
*/

#include <scl_cf.h>
#include <scl_memmgr.h>
#define EXPRESS_C
#include "express/basic.h"
#include <ctype.h>
Expand Down Expand Up @@ -138,7 +139,7 @@ Symbol * EXPRESS_get_symbol( Generic e ) {

Express EXPRESScreate() {
Express model = SCOPEcreate( OBJ_EXPRESS );
model->u.express = ( struct Express_ * )calloc( 1, sizeof( struct Express_ ) );
model->u.express = ( struct Express_ * )scl_calloc( 1, sizeof( struct Express_ ) );
return model;
}

Expand All @@ -157,7 +158,7 @@ static void EXPRESS_PATHinit() {
p = getenv( "EXPRESS_PATH" );
if( !p ) {
/* if no EXPRESS_PATH, search current directory anyway */
dir = ( Dir * )malloc( sizeof( Dir ) );
dir = ( Dir * )scl_malloc( sizeof( Dir ) );
dir->leaf = dir->full;
LISTadd( EXPRESS_path, ( Generic )dir );
} else {
Expand Down Expand Up @@ -189,7 +190,7 @@ static void EXPRESS_PATHinit() {
}
p++; /* leave p after terminating null */

dir = ( Dir * )malloc( sizeof( Dir ) );
dir = ( Dir * )scl_malloc( sizeof( Dir ) );

/* if it's just ".", make it as if it was */
/* just "" to make error messages cleaner */
Expand Down Expand Up @@ -388,7 +389,7 @@ void EXPRESSparse( Express model, FILE * fp, char * filename ) {
length -= 4;
}

model->u.express->basename = ( char * )malloc( length + 1 );
model->u.express->basename = ( char * )scl_malloc( length + 1 );
memcpy( model->u.express->basename, filename, length );
model->u.express->basename[length] = '\0';

Expand Down
1 change: 1 addition & 0 deletions src/express/fedex.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
*/

#include <scl_cf.h>
#include <scl_memmgr.h>
#include <scl_export.h>
#include "scl_version_string.h"
#include <stdlib.h>
Expand Down
9 changes: 5 additions & 4 deletions src/express/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
*
*/

#include <scl_memmgr.h>
#define HASH_C
#include <string.h>
#include <stdlib.h>
Expand Down Expand Up @@ -297,7 +298,7 @@ HASHdestroy( Hash_Table table ) {
p = q;
}
}
free( table->Directory[i] );
scl_free( table->Directory[i] );
}
}
HASH_Table_destroy( table );
Expand All @@ -315,11 +316,11 @@ void *
HASHfind( Hash_Table t, char * s ) {
// Element * ep;
struct Element_ *ep = NULL;
struct Element_ *e = malloc( sizeof * e );
struct Element_ *e = scl_malloc( sizeof * e );
e -> key = s;
e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */
ep = HASHsearch( t, e, HASH_FIND );
free(e);
scl_free(e);
return( ep ? ep->data : 0 );
}

Expand All @@ -329,7 +330,7 @@ void
HASHinsert( Hash_Table t, char * s, void * data ) {
Element e2;
// memset(e, 0, sizeof(s) + sizeof(data));
struct Element_ *e = malloc( sizeof * e );
struct Element_ *e = scl_malloc( sizeof * e );
e -> key = s;
e -> data = data;
e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */
Expand Down
9 changes: 5 additions & 4 deletions src/express/lexact.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* prettied up interface to print_objects_when_running
*/

#include <scl_memmgr.h>
#define LEX_ACTIONS_C
#include <stdlib.h>
#include <ctype.h>
Expand Down Expand Up @@ -308,7 +309,7 @@ SCANprocess_logical_literal( char * string ) {
break;
/* default will actually be triggered by 'UNKNOWN' keyword */
}
free( string );
scl_free( string );
return TOK_LOGICAL_LITERAL;
}

Expand All @@ -322,7 +323,7 @@ SCANprocess_identifier_or_keyword( void ) {

/* make uppercase copy */
len = strlen( yytext );
dest = test_string = ( char * )malloc( len + 1 );
dest = test_string = ( char * )scl_malloc( len + 1 );
for( src = yytext; *src; src++, dest++ ) {
*dest = ( islower( *src ) ? toupper( *src ) : *src );
}
Expand All @@ -338,7 +339,7 @@ SCANprocess_identifier_or_keyword( void ) {
case TOK_LOGICAL_LITERAL:
return SCANprocess_logical_literal( test_string );
default:
free( test_string );
scl_free( test_string );
return k->token;
}
}
Expand Down Expand Up @@ -534,7 +535,7 @@ SCANupperize( char * s ) {

char *
SCANstrdup( char * s ) {
char * s2 = ( char * )malloc( strlen( s ) + 1 );
char * s2 = ( char * )scl_malloc( strlen( s ) + 1 );
if( !s2 ) {
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/express/linklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* prettied up interface to print_objects_when_running
*/

#include <scl_memmgr.h>
#define LINKED_LIST_C
#include "express/linklist.h"

Expand Down
1 change: 1 addition & 0 deletions src/express/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Now you can say things like:
foo_destroy(foo1);

*/
#include <scl_memmgr.h>
#include <stdlib.h>
#include <string.h>
#include "express/memory.h"
Expand Down
3 changes: 2 additions & 1 deletion src/express/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* prettied up interface to print_objects_when_running
*/

#include <scl_memmgr.h>
#define OBJECT_C
#include <stdlib.h>
#include "express/object.h"
Expand All @@ -35,7 +36,7 @@ Symbol * UNK_get_symbol( Generic x ) {
void OBJinitialize() {
int i;

OBJ = ( struct Object * )malloc( MAX_OBJECT_TYPES * sizeof( struct Object ) );
OBJ = ( struct Object * )scl_malloc( MAX_OBJECT_TYPES * sizeof( struct Object ) );
for( i = 0; i < MAX_OBJECT_TYPES; i++ ) {
OBJ[i].get_symbol = UNK_get_symbol;
OBJ[i].type = "of unknown_type";
Expand Down
1 change: 1 addition & 0 deletions src/express/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
*/

#include <scl_cf.h>
#include <scl_memmgr.h>
#define RESOLVE_C
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
Expand Down
1 change: 1 addition & 0 deletions src/express/schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
*/

#include <scl_cf.h>
#include <scl_memmgr.h>
#define SCHEMA_C
#ifdef HAVE_UNISTD_H
# include <unistd.h>
Expand Down
1 change: 1 addition & 0 deletions src/express/scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* prettied up interface to print_objects_when_running
*/

#include <scl_memmgr.h>
#define SCOPE_C
#include "express/scope.h"
#include "express/resolve.h"
Expand Down
1 change: 1 addition & 0 deletions src/express/stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*
*/

#include <scl_memmgr.h>
#define STATEMENT_C
#include "express/stmt.h"

Expand Down
1 change: 1 addition & 0 deletions src/express/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Initial revision
*/

#include <scl_memmgr.h>
#define SYMBOL_C
#include "express/symbol.h"

Expand Down
1 change: 1 addition & 0 deletions src/express/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ This module implements the type abstraction. It is
*
*/

#include <scl_memmgr.h>
#define TYPE_C
#include "express/type.h"

Expand Down
1 change: 1 addition & 0 deletions src/express/variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
*
*/

#include <scl_memmgr.h>
#define VARIABLE_C
#include <stdlib.h>
#include "express/variable.h"
Expand Down