=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mansearch.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -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 +1,4 @@ -/* $OpenBSD: mansearch.c,v 1.46 2015/10/11 21:06:59 schwarze Exp $ */ +/* $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,11 +34,11 @@ #include #include -#include #include #include "mandoc.h" #include "mandoc_aux.h" +#include "mandoc_ohash.h" #include "manconf.h" #include "mansearch.h" @@ -85,9 +85,6 @@ 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 *); @@ -165,7 +162,6 @@ 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; @@ -176,11 +172,6 @@ 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; @@ -276,8 +267,7 @@ SQL_BIND_INT64(db, s, j, ep->bits); } - memset(&htab, 0, sizeof(struct ohash)); - ohash_init(&htab, 4, &info); + mandoc_ohash_init(&htab, 4, offsetof(struct match, pageid)); /* * Hash each entry on its [unique] document identifier. @@ -844,25 +834,4 @@ 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); }