=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mansearch.c,v retrieving revision 1.46 retrieving revision 1.47 diff -c -r1.46 -r1.47 *** src/usr.bin/mandoc/mansearch.c 2015/10/11 21:06:59 1.46 --- src/usr.bin/mandoc/mansearch.c 2015/10/13 15:50:15 1.47 *************** *** 1,4 **** ! /* $OpenBSD: mansearch.c,v 1.46 2015/10/11 21:06:59 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: mansearch.c,v 1.47 2015/10/13 15:50:15 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze *************** *** 34,44 **** #include #include - #include #include #include "mandoc.h" #include "mandoc_aux.h" #include "manconf.h" #include "mansearch.h" --- 34,44 ---- #include #include #include #include "mandoc.h" #include "mandoc_aux.h" + #include "mandoc_ohash.h" #include "manconf.h" #include "mansearch.h" *************** *** 85,93 **** const char *, int form); static char *buildoutput(sqlite3 *, sqlite3_stmt *, uint64_t, uint64_t); - static void *hash_alloc(size_t, void *); - static void hash_free(void *, void *); - static void *hash_calloc(size_t, size_t, void *); static struct expr *exprcomp(const struct mansearch *, int, char *[]); static void exprfree(struct expr *); --- 85,90 ---- *************** *** 165,171 **** sqlite3 *db; sqlite3_stmt *s, *s2; struct match *mp; - struct ohash_info info; struct ohash htab; unsigned int idx; size_t i, j, cur, maxres; --- 162,167 ---- *************** *** 176,186 **** return 0; } - info.calloc = hash_calloc; - info.alloc = hash_alloc; - info.free = hash_free; - info.key_offset = offsetof(struct match, pageid); - cur = maxres = 0; *res = NULL; --- 172,177 ---- *************** *** 276,283 **** SQL_BIND_INT64(db, s, j, ep->bits); } ! memset(&htab, 0, sizeof(struct ohash)); ! ohash_init(&htab, 4, &info); /* * Hash each entry on its [unique] document identifier. --- 267,273 ---- SQL_BIND_INT64(db, s, j, ep->bits); } ! mandoc_ohash_init(&htab, 4, offsetof(struct match, pageid)); /* * Hash each entry on its [unique] document identifier. *************** *** 844,868 **** free(p); p = pp; } - } - - static void * - hash_calloc(size_t nmemb, size_t sz, void *arg) - { - - return mandoc_calloc(nmemb, sz); - } - - static void * - hash_alloc(size_t sz, void *arg) - { - - return mandoc_malloc(sz); - } - - static void - hash_free(void *p, void *arg) - { - - free(p); } --- 834,837 ----