File tree Expand file tree Collapse file tree 5 files changed +23
-17
lines changed
Expand file tree Collapse file tree 5 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ void MemFini( void )
7575{
7676#ifdef TRMEM
7777 if ( memHandle != NULL ) {
78- _trmem_prt_list ( memHandle );
78+ _trmem_prt_list_ex ( memHandle , 100 );
7979 _trmem_close ( memHandle );
8080 if ( memFile != NULL ) {
8181 fclose ( memFile );
@@ -107,11 +107,16 @@ void *YaccCalloc( size_t n, size_t size )
107107{
108108 void * ptr ;
109109
110- ptr = YaccAlloc ( n * size );
110+ size *= n ;
111+ #ifdef TRMEM
112+ ptr = _trmem_alloc ( size , _trmem_guess_who (), memHandle );
113+ #else
114+ ptr = malloc ( size );
115+ #endif
111116 if ( ptr == NULL ) {
112117 msg ( "Out of memory\n" );
113118 }
114- memset ( ptr , 0 , n * size );
119+ memset ( ptr , 0 , size );
115120 return ( ptr );
116121}
117122
@@ -144,6 +149,7 @@ void YaccFree( void *ptr )
144149}
145150
146151char * YaccStrDup ( const char * str )
152+ /*********************************/
147153{
148154 size_t size ;
149155 char * ptr ;
Original file line number Diff line number Diff line change @@ -523,11 +523,11 @@ void lalr1( void )
523523 puts ( "internal error" );
524524 }
525525 FREE ( stk );
526+ FREE ( look );
526527 Conflict ();
527528 nbstate = nstate ;
528- FreeSet ( rset );
529- FreeSet ( lset );
530- FREE ( look );
529+ // FreeSet( rset );
530+ // FreeSet( lset );
531531}
532532
533533void showstates ( void )
Original file line number Diff line number Diff line change 3838#include "yaccins.h"
3939#include "alloc.h"
4040
41- typedef struct traceback traceback ;
42- struct traceback {
43- traceback * next ;
44- a_state * state ;
45- a_sym * sym ;
46- };
41+
42+ typedef struct traceback {
43+ struct traceback * next ;
44+ a_state * state ;
45+ a_sym * sym ;
46+ } traceback ;
4747
4848static void pushTrace ( traceback * * h , a_state * state , a_sym * sym )
4949{
@@ -60,8 +60,7 @@ static void popTrace( traceback **h )
6060{
6161 traceback * token ;
6262
63- token = * h ;
64- if ( token != NULL ) {
63+ if ( (token = * h ) != NULL ) {
6564 * h = token -> next ;
6665 FREE ( token );
6766 }
Original file line number Diff line number Diff line change 3838#include "alloc.h"
3939#include "walloca.h"
4040
41+
4142FILE * yaccin ;
4243char * loadpath ;
4344char * srcname_norm = NULL ;
@@ -236,7 +237,7 @@ static char *fname_normalize( char *name )
236237 char * p ;
237238 char * dst ;
238239
239- p = dst = malloc ( strlen ( name ) + 1 );
240+ p = dst = MALLOC ( strlen ( name ) + 1 , char );
240241 while ( (c = * name ++ ) != '\0' ) {
241242 if ( c == '\\' )
242243 c = '/' ;
@@ -318,7 +319,7 @@ int main( int argc, char **argv )
318319 loadpath = argv [0 ];
319320 * getname ( loadpath ) = '\0' ;
320321 srcname = argv [i ];
321- if ( ! strrchr ( srcname , '.' ) ) {
322+ if ( strrchr ( srcname , '.' ) == NULL ) {
322323 srcname = alloca ( strlen ( argv [i ] )+ 3 );
323324 srcname = strcat ( strcpy ( srcname , argv [i ] ), ".y" );
324325 }
Original file line number Diff line number Diff line change 3737#include <stdlib.h>
3838
3939#define MALLOC (n ,t ) ((t *)YaccAlloc((n) * sizeof(t)))
40- #define REALLOC (p ,n ,t ) ((t *)YaccRealloc((char *)p ,(n) * sizeof(t)))
40+ #define REALLOC (p ,n ,t ) ((t *)YaccRealloc((p) ,(n) * sizeof(t)))
4141#define CALLOC (n ,t ) ((t *)YaccCalloc((n),sizeof(t)))
4242#define FREE (n ) YaccFree((n))
4343#define STRDUP (p ) YaccStrDup((p))
You can’t perform that action at this time.
0 commit comments