Added use of scl_memmgr to express library.

* 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:08 +01:00
parent 82c84e7337
commit 4d6d249dad
21 changed files with 38 additions and 16 deletions
+3 -1
View File
@@ -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 )
@@ -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")
+1
View File
@@ -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"
+1
View File
@@ -29,6 +29,7 @@
* prettied up interface to print_objects_when_running
*/
#include <scl_memmgr.h>
#define CASE_ITEM_C
#include "express/caseitem.h"
+1
View File
@@ -33,6 +33,7 @@
* Initial revision
*/
#include <scl_memmgr.h>
#define DICTIONARY_C
#include "express/dict.h"
#include "express/object.h"
+1
View File
@@ -111,6 +111,7 @@
*
*/
#include <scl_memmgr.h>
#define ENTITY_C
#include "express/entity.h"
#include "express/express.h"
+3 -2
View File
@@ -52,6 +52,7 @@
*/
#include <scl_cf.h>
#include <scl_memmgr.h>
#include <stdlib.h>
#include <setjmp.h>
#ifdef HAVE_UNISTD_H
@@ -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();
@@ -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;
+1
View File
@@ -71,6 +71,7 @@
*/
#include <scl_cf.h>
#include <scl_memmgr.h>
#define EXPRESSION_C
#ifdef HAVE_UNISTD_H
+5 -4
View File
@@ -69,6 +69,7 @@
*/
#include <scl_cf.h>
#include <scl_memmgr.h>
#define EXPRESS_C
#include "express/basic.h"
#include <ctype.h>
@@ -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;
}
@@ -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 {
@@ -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 */
@@ -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';
+1
View File
@@ -72,6 +72,7 @@
*/
#include <scl_cf.h>
#include <scl_memmgr.h>
#include <scl_export.h>
#include "scl_version_string.h"
#include <stdlib.h>
+5 -4
View File
@@ -105,6 +105,7 @@
*
*/
#include <scl_memmgr.h>
#define HASH_C
#include <string.h>
#include <stdlib.h>
@@ -297,7 +298,7 @@ HASHdestroy( Hash_Table table ) {
p = q;
}
}
free( table->Directory[i] );
scl_free( table->Directory[i] );
}
}
HASH_Table_destroy( table );
@@ -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 );
}
@@ -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 */
+5 -4
View File
@@ -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>
@@ -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;
}
@@ -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 );
}
@@ -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;
}
}
@@ -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;
}
+1
View File
@@ -21,6 +21,7 @@
* prettied up interface to print_objects_when_running
*/
#include <scl_memmgr.h>
#define LINKED_LIST_C
#include "express/linklist.h"
+1
View File
@@ -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"
+2 -1
View File
@@ -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"
@@ -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";
+1
View File
@@ -56,6 +56,7 @@
*/
#include <scl_cf.h>
#include <scl_memmgr.h>
#define RESOLVE_C
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
+1
View File
@@ -46,6 +46,7 @@
*/
#include <scl_cf.h>
#include <scl_memmgr.h>
#define SCHEMA_C
#ifdef HAVE_UNISTD_H
# include <unistd.h>
+1
View File
@@ -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"
+1
View File
@@ -40,6 +40,7 @@
*
*/
#include <scl_memmgr.h>
#define STATEMENT_C
#include "express/stmt.h"
+1
View File
@@ -32,6 +32,7 @@
* Initial revision
*/
#include <scl_memmgr.h>
#define SYMBOL_C
#include "express/symbol.h"
+1
View File
@@ -122,6 +122,7 @@ This module implements the type abstraction. It is
*
*/
#include <scl_memmgr.h>
#define TYPE_C
#include "express/type.h"
+1
View File
@@ -83,6 +83,7 @@
*
*/
#include <scl_memmgr.h>
#define VARIABLE_C
#include <stdlib.h>
#include "express/variable.h"