diff options
Diffstat (limited to 'man_hash.c')
-rw-r--r-- | man_hash.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -37,9 +37,13 @@ man_hash_alloc(void) int *htab; int i, j, x; - htab = calloc(26 * 5, sizeof(int)); + /* Initialised to -1. */ + + htab = malloc(26 * 5 * sizeof(int)); if (NULL == htab) return(NULL); + for (i = 0; i < 26 * 5; i++) + htab[i] = -1; for (i = 0; i < MAN_MAX; i++) { x = man_macronames[i][0]; @@ -51,7 +55,7 @@ man_hash_alloc(void) x *= 5; for (j = 0; j < 5; j++) - if (0 == htab[x + j]) { + if (-1 == htab[x + j]) { htab[x + j] = i; break; } @@ -80,7 +84,7 @@ man_hash_find(const void *arg, const char *tmp) x *= 5; for (i = 0; i < 5; i++) { - if (0 == (tok = htab[x + i])) + if (-1 == (tok = htab[x + i])) return(MAN_MAX); if (0 == strcmp(tmp, man_macronames[tok])) return(tok); |