|
From: Paul P. <ppr...@us...> - 2004-07-27 04:31:12
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5832 Modified Files: fdict.c fdict.h fsystem.c ftype.h main.c Log Message: - fixed bug where attached dictionaries could be forget'ed from if they were not shared with other FSYSTEMs - tempfile in main.c for loading scripts, so no memory leak possible Index: fdict.c =================================================================== RCS file: /cvsroot/forthy/forthy/fdict.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fdict.c 16 Nov 2003 16:24:58 -0000 1.3 --- fdict.c 27 Jul 2004 04:31:02 -0000 1.4 *************** *** 53,56 **** --- 53,57 ---- table->list=NULL; table->refcount=1; + table->attached=FALSE; return table; } *************** *** 292,296 **** dict->refcount++; ! return dict; } --- 293,297 ---- dict->refcount++; ! dict->attached=TRUE; return dict; } *************** *** 302,305 **** --- 303,313 ---- } + + int dict_attached(FDICT *dict) + { + return dict->attached; + } + + // TODO: Delete all symbols, do cleanup on any buffers and user types in the // list Index: ftype.h =================================================================== RCS file: /cvsroot/forthy/forthy/ftype.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ftype.h 25 Jul 2004 20:25:47 -0000 1.5 --- ftype.h 27 Jul 2004 04:31:02 -0000 1.6 *************** *** 72,75 **** --- 72,76 ---- { int refcount; + int attached; FSYMREC *list; // FSYMREC *fence; Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** main.c 26 Jul 2004 03:28:30 -0000 1.16 --- main.c 27 Jul 2004 04:31:02 -0000 1.17 *************** *** 9,12 **** --- 9,13 ---- static int user_var=0; static int hex=0; + static char *tempfile=NULL; #ifdef FORTIFY *************** *** 59,71 **** { int ret; - char *script; ! script=load_text(filename); ! if(!script) return FS_ERROR; ! ret=fs_load_input(sys, script); ! free(script); return ret; --- 60,75 ---- { int ret; ! if(tempfile) ! free(tempfile); ! tempfile=load_text(filename); ! ! if(!tempfile) return FS_ERROR; ! ret=fs_load_input(sys, tempfile); ! free(tempfile); ! tempfile=NULL; return ret; *************** *** 1901,1904 **** --- 1905,1911 ---- fs_sys_exit(&sys); + if(tempfile) + free(tempfile); + #ifdef _DEBUG fs_sys_exit(&sub); Index: fsystem.c =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** fsystem.c 25 Jul 2004 20:25:47 -0000 1.10 --- fsystem.c 27 Jul 2004 04:31:02 -0000 1.11 *************** *** 1170,1174 **** // Can't delete words from shared dictionaries ! if(dict_refcount(where)>1) VOID_THROW(sys, FS_ERROR); --- 1170,1174 ---- // Can't delete words from shared dictionaries ! if(dict_attached(where)) VOID_THROW(sys, FS_ERROR); Index: fdict.h =================================================================== RCS file: /cvsroot/forthy/forthy/fdict.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fdict.h 7 Aug 2003 01:22:55 -0000 1.1 --- fdict.h 27 Jul 2004 04:31:02 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- FDICT *dict_attach(FDICT *table); int dict_refcount(FDICT *dict); + int dict_attached(FDICT *dict); FSYMREC *dict_new(FDICT *table, char *name, FSYMREC *vocab, int flags); |