/* -*-c-*-
*
- * $Id: sym.c,v 1.12 2001/01/20 11:49:37 mdw Exp $
+ * $Id: sym.c,v 1.13 2001/01/25 21:14:49 mdw Exp $
*
* Symbol table management
*
/*----- Revision history --------------------------------------------------*
*
* $Log: sym.c,v $
+ * Revision 1.13 2001/01/25 21:14:49 mdw
+ * Always add a terminating null, and don't count it in the length.
+ *
* Revision 1.12 2001/01/20 11:49:37 mdw
* Export tuning parameters from header file, for the benefit of other
* hashtable implementations. Change the storage of symbol names: store
/* --- Find the correct bin --- */
- len = l < 0 ? strlen(n) + 1 : l;
+ len = l < 0 ? strlen(n) : l;
CRC32(hash, 0, n, len);
bin = HASH_BIN(&t->t, hash);
* The name is attached to the end of the symbol block.
*/
- q = x_alloc(t->t.a, sz + len);
+ q = x_alloc(t->t.a, sz + len + 1);
q->b.next = *bin;
q->b.hash = hash;
q->name = (char *)q + sz;
memcpy(q->name, n, len);
+ q->name[len] = 0;
q->len = len;
*bin = &q->b;