chiark
/
gitweb
/
~mdw
/
mLib
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f41204b
)
Always add a terminating null, and don't count it in the length.
author
mdw
<mdw>
Thu, 25 Jan 2001 21:14:49 +0000
(21:14 +0000)
committer
mdw
<mdw>
Thu, 25 Jan 2001 21:14:49 +0000
(21:14 +0000)
sym.c
patch
|
blob
|
blame
|
history
diff --git
a/sym.c
b/sym.c
index c6d1e436cd8705957dedd7d960ef9d5f4530a0ae..3aea8c74e7f28423dbc37040922cfe38bb5811bd 100644
(file)
--- a/
sym.c
+++ b/
sym.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: sym.c,v 1.1
2 2001/01/20 11:49:37
mdw Exp $
+ * $Id: sym.c,v 1.1
3 2001/01/25 21:14:49
mdw Exp $
*
* Symbol table management
*
*
* Symbol table management
*
@@
-30,6
+30,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: sym.c,v $
/*----- 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
* 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
@@
-175,7
+178,7
@@
void *sym_find(sym_table *t, const char *n, long l, size_t sz, unsigned *f)
/* --- Find the correct bin --- */
/* --- 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);
CRC32(hash, 0, n, len);
bin = HASH_BIN(&t->t, hash);
@@
-212,11
+215,12
@@
void *sym_find(sym_table *t, const char *n, long l, size_t sz, unsigned *f)
* The name is attached to the end of the symbol block.
*/
* 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->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;
q->len = len;
*bin = &q->b;