X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/a5d14edee10f6c07549259fd145bda7d00c0d26f..7683d67d4183a53aa10f1fcf31cb997957952a32:/sym.c diff --git a/sym.c b/sym.c index 5c18a18..6ddc45c 100644 --- a/sym.c +++ b/sym.c @@ -1,34 +1,47 @@ /* -*-c-*- * - * $Id: sym.c,v 1.2 1998/11/26 19:27:33 mdw Exp $ + * $Id: sym.c,v 1.6 1999/05/26 21:08:31 mdw Exp $ * * Symbol table management * * (c) 1998 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the mLib utilities library. * * mLib is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * * mLib is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with mLib; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with mLib; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. */ /*----- Revision history --------------------------------------------------* * * $Log: sym.c,v $ + * Revision 1.6 1999/05/26 21:08:31 mdw + * Rename symbols in line with newer conventions. + * + * Revision 1.5 1999/05/13 22:48:37 mdw + * Twiddle the extension threshold. Change `-ise' to `-ize' throughout. + * + * Revision 1.4 1999/05/06 19:51:35 mdw + * Reformatted the LGPL notice a little bit. + * + * Revision 1.3 1999/05/05 18:50:31 mdw + * Change licensing conditions to LGPL. + * * Revision 1.2 1998/11/26 19:27:33 mdw * Move SYM_NAME into the header file. Fix bugs. * @@ -71,26 +84,23 @@ * and the limit %$l$% satisfy the relation %$n < bl$%; if a new item is * added to the table and this relation is found to be false, the table is * doubled in size. - * - * The current function gives %$l = {3n \over 4}$%, which appears to be - * reasonable on the face of things. */ -#define SYM_LIMIT(n) (((n) * 3) >> 2) /* Load factor for growing table */ +#define SYM_LIMIT(n) ((n) * 4) /* Load factor for growing table */ /*----- Main code ---------------------------------------------------------*/ -/* --- @sym_createTable@ --- * +/* --- @sym_create@ --- * * - * Arguments: @sym_table *t@ = symbol table to initialise + * Arguments: @sym_table *t@ = symbol table to initialize * * Returns: --- * - * Use: Initialises the given symbol table. Raises @EXC_NOMEM@ if + * Use: Initializes the given symbol table. Raises @EXC_NOMEM@ if * there isn't enough memory. */ -void sym_createTable(sym_table *t) +void sym_create(sym_table *t) { size_t i; @@ -107,7 +117,7 @@ void sym_createTable(sym_table *t) TRACK_POP; } -/* --- @sym_destroyTable@ --- * +/* --- @sym_destroy@ --- * * * Arguments: @sym_table *t@ = pointer to symbol table in question * @@ -117,7 +127,7 @@ void sym_createTable(sym_table *t) * occupy. */ -void sym_destroyTable(sym_table *t) +void sym_destroy(sym_table *t) { size_t i; sym_base *p, *q; @@ -215,7 +225,7 @@ void *sym_find(sym_table *t, const char *n, long l, size_t sz, unsigned *f) if (f) *f = 0; /* Failed to find the block */ if (!sz) return (0); /* Return zero if not creating */ - /* --- Create a new symbol block and initialise it --- */ + /* --- Create a new symbol block and initialize it --- */ { TRACK_CTX("new symbol creation"); @@ -353,7 +363,7 @@ void sym_remove(sym_table *t, void *b) t->c++; } -/* --- @sym_createIter@ --- * +/* --- @sym_mkiter@ --- * * * Arguments: @sym_iter *i@ = pointer to an iterator object * @sym_table *t@ = pointer to a symbol table object @@ -364,7 +374,7 @@ void sym_remove(sym_table *t, void *b) * iterate through a symbol table. */ -void sym_createIter(sym_iter *i, sym_table *t) +void sym_mkiter(sym_iter *i, sym_table *t) { i->t = t; i->i = 0; @@ -435,7 +445,7 @@ int main(void) sym_table tbl; int entries; - /* --- Initialise for reading the file --- */ + /* --- Initialize for reading the file --- */ sz = BUFSIZ; buff = xmalloc(sz + 1); @@ -489,7 +499,7 @@ int main(void) flag[i] = 0; entries = 0; - sym_createTable(&tbl); + sym_create(&tbl); for (;;) { i = (unsigned)rand() % sz; @@ -562,7 +572,7 @@ int main(void) ntbl = xmalloc(sz * sizeof(sym_word *)); memcpy(ntbl, flag, sz * sizeof(sym_word *)); - sym_createIter(&it, &tbl); + sym_mkiter(&it, &tbl); while ((w = sym_next(&it)) != 0) { if (ntbl[w->i] == 0)