-/* $Id: man_hash.c,v 1.7 2009/04/12 19:45:26 kristaps Exp $ */
+/* $Id: man_hash.c,v 1.10 2009/06/18 10:32:00 kristaps Exp $ */
/*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
+ * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
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 = 1; i < MAN_MAX; i++) {
+ for (i = 0; i < MAN_MAX; i++) {
x = man_macronames[i][0];
assert((x >= 65 && x <= 90) ||
x *= 5;
for (j = 0; j < 5; j++)
- if (0 == htab[x + j]) {
+ if (-1 == htab[x + j]) {
htab[x + j] = i;
break;
}
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);