Skip to content

Commit 4d6d249

Browse files
committed
Added use of scl_memmgr to express library.
* Replaced malloc, calloc, realloc and free with scl_memmgr versions. * Added scl_memmgr.h includes.
1 parent 82c84e7 commit 4d6d249

File tree

21 files changed

+38
-16
lines changed

21 files changed

+38
-16
lines changed

src/express/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ SET(EXPRESS_PRIVATE_HDRS
7070
include_directories(
7171
${CMAKE_CURRENT_BINARY_DIR}
7272
${CMAKE_CURRENT_SOURCE_DIR}
73+
${SCL_SOURCE_DIR}/src/base
7374
)
7475

7576
add_definitions( -DFLEX )
@@ -80,9 +81,10 @@ endif()
8081

8182
if(BORLAND)
8283
add_definitions( -D__STDC__ )
84+
add_definitions( -DSCL_BASE_DLL_IMPORTS )
8385
endif()
8486

85-
SCL_ADDLIB(express "${EXPRESS_SOURCES}" "")
87+
SCL_ADDLIB(express "${EXPRESS_SOURCES}" "base")
8688

8789
if(APPLE)
8890
set_target_properties(express PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")

src/express/alg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* prettied up interface to print_objects_when_running
3939
*/
4040

41+
#include <scl_memmgr.h>
4142
#define ALGORITHM_C
4243
#include "express/alg.h"
4344
#include "express/object.h"

src/express/caseitem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* prettied up interface to print_objects_when_running
3030
*/
3131

32+
#include <scl_memmgr.h>
3233
#define CASE_ITEM_C
3334
#include "express/caseitem.h"
3435

src/express/dict.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* Initial revision
3434
*/
3535

36+
#include <scl_memmgr.h>
3637
#define DICTIONARY_C
3738
#include "express/dict.h"
3839
#include "express/object.h"

src/express/entity.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
*
112112
*/
113113

114+
#include <scl_memmgr.h>
114115
#define ENTITY_C
115116
#include "express/entity.h"
116117
#include "express/express.h"

src/express/error.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*/
5353

5454
#include <scl_cf.h>
55+
#include <scl_memmgr.h>
5556
#include <stdlib.h>
5657
#include <setjmp.h>
5758
#ifdef HAVE_UNISTD_H
@@ -105,7 +106,7 @@ void ERRORinitialize( void ) {
105106
ERROR_syntax_expecting =
106107
ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT );
107108

108-
ERROR_string_base = ( char * )malloc( ERROR_MAX_SPACE );
109+
ERROR_string_base = ( char * )scl_malloc( ERROR_MAX_SPACE );
109110
ERROR_start_message_buffer();
110111

111112

@@ -410,7 +411,7 @@ void ERRORnospace() {
410411
Error ERRORcreate( char * message, Severity severity ) {
411412
Error n;
412413

413-
n = ( struct Error_ * )malloc( sizeof( struct Error_ ) );
414+
n = ( struct Error_ * )scl_malloc( sizeof( struct Error_ ) );
414415
n->message = message;
415416
n->severity = severity;
416417
n->enabled = true;

src/express/expr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
*/
7272

7373
#include <scl_cf.h>
74+
#include <scl_memmgr.h>
7475
#define EXPRESSION_C
7576

7677
#ifdef HAVE_UNISTD_H

src/express/express.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
*/
7070

7171
#include <scl_cf.h>
72+
#include <scl_memmgr.h>
7273
#define EXPRESS_C
7374
#include "express/basic.h"
7475
#include <ctype.h>
@@ -138,7 +139,7 @@ Symbol * EXPRESS_get_symbol( Generic e ) {
138139

139140
Express EXPRESScreate() {
140141
Express model = SCOPEcreate( OBJ_EXPRESS );
141-
model->u.express = ( struct Express_ * )calloc( 1, sizeof( struct Express_ ) );
142+
model->u.express = ( struct Express_ * )scl_calloc( 1, sizeof( struct Express_ ) );
142143
return model;
143144
}
144145

@@ -157,7 +158,7 @@ static void EXPRESS_PATHinit() {
157158
p = getenv( "EXPRESS_PATH" );
158159
if( !p ) {
159160
/* if no EXPRESS_PATH, search current directory anyway */
160-
dir = ( Dir * )malloc( sizeof( Dir ) );
161+
dir = ( Dir * )scl_malloc( sizeof( Dir ) );
161162
dir->leaf = dir->full;
162163
LISTadd( EXPRESS_path, ( Generic )dir );
163164
} else {
@@ -189,7 +190,7 @@ static void EXPRESS_PATHinit() {
189190
}
190191
p++; /* leave p after terminating null */
191192

192-
dir = ( Dir * )malloc( sizeof( Dir ) );
193+
dir = ( Dir * )scl_malloc( sizeof( Dir ) );
193194

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

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

src/express/fedex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
*/
7373

7474
#include <scl_cf.h>
75+
#include <scl_memmgr.h>
7576
#include <scl_export.h>
7677
#include "scl_version_string.h"
7778
#include <stdlib.h>

src/express/hash.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
*
106106
*/
107107

108+
#include <scl_memmgr.h>
108109
#define HASH_C
109110
#include <string.h>
110111
#include <stdlib.h>
@@ -297,7 +298,7 @@ HASHdestroy( Hash_Table table ) {
297298
p = q;
298299
}
299300
}
300-
free( table->Directory[i] );
301+
scl_free( table->Directory[i] );
301302
}
302303
}
303304
HASH_Table_destroy( table );
@@ -315,11 +316,11 @@ void *
315316
HASHfind( Hash_Table t, char * s ) {
316317
// Element * ep;
317318
struct Element_ *ep = NULL;
318-
struct Element_ *e = malloc( sizeof * e );
319+
struct Element_ *e = scl_malloc( sizeof * e );
319320
e -> key = s;
320321
e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */
321322
ep = HASHsearch( t, e, HASH_FIND );
322-
free(e);
323+
scl_free(e);
323324
return( ep ? ep->data : 0 );
324325
}
325326

@@ -329,7 +330,7 @@ void
329330
HASHinsert( Hash_Table t, char * s, void * data ) {
330331
Element e2;
331332
// memset(e, 0, sizeof(s) + sizeof(data));
332-
struct Element_ *e = malloc( sizeof * e );
333+
struct Element_ *e = scl_malloc( sizeof * e );
333334
e -> key = s;
334335
e -> data = data;
335336
e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */

0 commit comments

Comments
 (0)