[Plib-cvs] plib/src/psl pslCompiler.h,1.33,1.34 pslProgram.cxx,1.17,1.18
Brought to you by:
sjbaker
From: James J. <pu...@us...> - 2004-08-05 00:57:47
|
Update of /cvsroot/plib/plib/src/psl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18071 Modified Files: pslCompiler.h pslProgram.cxx Log Message: Implements some reference-counting in PSL, in accordance with Jonathan Wheare's e-mail of 4/20/04 at 9:20 AM. Index: pslCompiler.h =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslCompiler.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- pslCompiler.h 6 Jan 2003 05:10:13 -0000 1.33 +++ pslCompiler.h 5 Aug 2004 00:57:37 -0000 1.34 @@ -51,6 +51,8 @@ class pslCompiler { + int ref_count; // reference count. Clean up when this reaches zero + /* File I/O and preprocessor */ int getChar () ; @@ -313,6 +315,7 @@ const pslExtension *_extn, const char *_progName ) { + ref_count = 1; program = prog ; progName = ulStrDup ( _progName ) ; @@ -344,6 +347,21 @@ } } + void ref() + { + ref_count++; + } + + void deref() + { + ref_count--; + if(ref_count < 1) + { + delete [] code; + delete this; + } + } + const pslExtension *getExtensions () const { return extensions ; } int printInstruction ( FILE *fd, int addr ) const ; Index: pslProgram.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/psl/pslProgram.cxx,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- pslProgram.cxx 6 Jan 2003 05:10:14 -0000 1.17 +++ pslProgram.cxx 5 Aug 2004 00:57:38 -0000 1.18 @@ -86,9 +86,8 @@ /* We need ref-counting on code/compiler */ /* DEBUG-ME! */ delete [] progName ; - delete compiler ; delete context ; - delete [] code ; + compiler -> ref(); } |