X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/ce7034f0b1dd4c347e9230f82cd9af11d2210059..35b9a1d988c06908076e3a6eeae55b1147879607:/src/fileTable.c diff --git a/src/fileTable.c b/src/fileTable.c index dd04efc..dee235e 100644 --- a/src/fileTable.c +++ b/src/fileTable.c @@ -1,6 +1,6 @@ /* ** Splint - annotation-assisted static program checker -** Copyright (C) 1994-2002 University of Virginia, +** Copyright (C) 1994-2003 University of Virginia, ** Massachusetts Institute of Technology ** ** This program is free software; you can redistribute it and/or modify it @@ -192,7 +192,6 @@ ftentry_create (/*@keep@*/ cstring tn, bool temp, fileType typ, fileId der) } t->fname = tn; - t->basename = cstring_undefined; t->ftemp = temp; t->ftype = typ; @@ -226,10 +225,11 @@ fileTable_create () ft->nopen = 0; ft->nopenspace = FTBASESIZE; ft->openelements = (foentry *) dmalloc (FTBASESIZE * sizeof (*ft->openelements)); - + return (ft); } +/*@-bounds@*/ static void fileTable_grow (fileTable ft) { @@ -250,7 +250,7 @@ fileTable_grow (fileTable ft) sfree (ft->elements); ft->elements = newent; } - +/*@=bounds@*/ static void fileTable_growOpen (fileTable ft) { @@ -288,13 +288,17 @@ fileTable_internAddEntry (fileTable ft, /*@only@*/ ftentry e) { cstring sd = cstring_downcase (e->fname); cstringTable_insert (ft->htable, sd, ft->nentries); - cstring_free (e->fname); } else { - cstringTable_insert (ft->htable, e->fname, ft->nentries); + cstringTable_insert (ft->htable, cstring_copy (e->fname), ft->nentries); } + /* evans 2002-07-12: + Before, there was no cstring_copy above, and e->fname was free'd in the if branch. + Splint should have caught this, and produced a warning for this assignment. + Why not? + */ ft->elements[ft->nentries] = e; ft->nentries++; @@ -485,7 +489,6 @@ fileTable_addXHFile (fileTable ft, cstring name) return (fileTable_addFilePrim (ft, name, FALSE, FILE_XH, fileId_invalid)); } -# ifndef NOLCL fileId fileTable_addImportFile (fileTable ft, cstring name) { @@ -497,11 +500,8 @@ fileTable_addLCLFile (fileTable ft, cstring name) { return (fileTable_addFilePrim (ft, name, FALSE, FILE_HEADER, fileId_invalid)); } -# endif -# ifndef NOLCL static int tmpcounter = 0; -# endif fileId fileTable_addMacrosFile (fileTable ft) @@ -563,7 +563,6 @@ fileTable_addCTempFile (fileTable ft, fileId fid) return res; } -# ifndef NOLCL fileId fileTable_addltemp (fileTable ft) { @@ -610,7 +609,6 @@ fileTable_addltemp (fileTable ft) cstring_free (newname); return (ret); } -# endif bool fileTable_exists (fileTable ft, cstring s) @@ -879,6 +877,7 @@ fileTable_free (/*@only@*/ fileTable f) cstringTable_free (f->htable); sfree (f->elements); + sfree (f->openelements); /*!! why didn't splint report this? */ sfree (f); } @@ -930,7 +929,7 @@ static /*@only@*/ cstring makeTempName (cstring dir, cstring pre, cstring suf) static int pid = 0; static /*@owned@*/ char *msg = NULL; static /*@only@*/ cstring pidname = NULL; - int maxlen; + size_t maxlen; cstring smsg; llassert (cstring_length (pre) <= 3); @@ -1013,7 +1012,11 @@ fileTable_addOpen (fileTable ft, /*@observer@*/ FILE *f, /*@only@*/ cstring fnam FILE *fileTable_createFile (fileTable ft, cstring fname) { - int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR); +# ifdef WIN32 + int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL); /* not supported by VS.net: , S_IRUSR | S_IWUSR); */ +# else + int fdesc = open (cstring_toCharsSafe (fname), O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, S_IRUSR | S_IWUSR); +# endif if (fdesc == -1) {