aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mansearch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-10-13 15:53:05 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-10-13 15:53:05 +0000
commite47784200392e2dea53b3decd3ceb23e1e2a0ca6 (patch)
tree06f0453944a7435752f1560277357ba9f8bec536 /mansearch.c
parent899e2d9f117239c813531c03cd4eb41d120bce26 (diff)
downloadmandoc-e47784200392e2dea53b3decd3ceb23e1e2a0ca6.tar.gz
mandoc-e47784200392e2dea53b3decd3ceb23e1e2a0ca6.tar.zst
mandoc-e47784200392e2dea53b3decd3ceb23e1e2a0ca6.zip
Reduce the amount of code by moving the three copies of the ohash
callback functions into one common place, preparing for the use of ohash for some additional purposes. No functional change.
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c41
1 files changed, 3 insertions, 38 deletions
diff --git a/mansearch.c b/mansearch.c
index def52984..41fdb499 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -1,4 +1,4 @@
-/* $Id: mansearch.c,v 1.59 2015/10/11 21:12:55 schwarze Exp $ */
+/* $Id: mansearch.c,v 1.60 2015/10/13 15:53:05 schwarze Exp $ */
/*
* Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -35,11 +35,6 @@
#include <string.h>
#include <unistd.h>
-#if HAVE_OHASH
-#include <ohash.h>
-#else
-#include "compat_ohash.h"
-#endif
#include <sqlite3.h>
#ifndef SQLITE_DETERMINISTIC
#define SQLITE_DETERMINISTIC 0
@@ -47,6 +42,7 @@
#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc_ohash.h"
#include "manconf.h"
#include "mansearch.h"
@@ -93,9 +89,6 @@ static void buildnames(const struct mansearch *,
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 *);
@@ -173,7 +166,6 @@ mansearch(const struct mansearch *search,
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;
@@ -184,11 +176,6 @@ mansearch(const struct mansearch *search,
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;
@@ -284,8 +271,7 @@ mansearch(const struct mansearch *search,
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.
@@ -853,24 +839,3 @@ exprfree(struct expr *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);
-}