version 1.59, 2015/10/11 21:12:55 |
version 1.60, 2015/10/13 15:53:05 |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#if HAVE_OHASH |
|
#include <ohash.h> |
|
#else |
|
#include "compat_ohash.h" |
|
#endif |
|
#include <sqlite3.h> |
#include <sqlite3.h> |
#ifndef SQLITE_DETERMINISTIC |
#ifndef SQLITE_DETERMINISTIC |
#define SQLITE_DETERMINISTIC 0 |
#define SQLITE_DETERMINISTIC 0 |
|
|
|
|
#include "mandoc.h" |
#include "mandoc.h" |
#include "mandoc_aux.h" |
#include "mandoc_aux.h" |
|
#include "mandoc_ohash.h" |
#include "manconf.h" |
#include "manconf.h" |
#include "mansearch.h" |
#include "mansearch.h" |
|
|
Line 93 static void buildnames(const struct mansearch *, |
|
Line 89 static void buildnames(const struct mansearch *, |
|
const char *, int form); |
const char *, int form); |
static char *buildoutput(sqlite3 *, sqlite3_stmt *, |
static char *buildoutput(sqlite3 *, sqlite3_stmt *, |
uint64_t, uint64_t); |
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 *, |
static struct expr *exprcomp(const struct mansearch *, |
int, char *[]); |
int, char *[]); |
static void exprfree(struct expr *); |
static void exprfree(struct expr *); |
Line 173 mansearch(const struct mansearch *search, |
|
Line 166 mansearch(const struct mansearch *search, |
|
sqlite3 *db; |
sqlite3 *db; |
sqlite3_stmt *s, *s2; |
sqlite3_stmt *s, *s2; |
struct match *mp; |
struct match *mp; |
struct ohash_info info; |
|
struct ohash htab; |
struct ohash htab; |
unsigned int idx; |
unsigned int idx; |
size_t i, j, cur, maxres; |
size_t i, j, cur, maxres; |
Line 184 mansearch(const struct mansearch *search, |
|
Line 176 mansearch(const struct mansearch *search, |
|
return 0; |
return 0; |
} |
} |
|
|
info.calloc = hash_calloc; |
|
info.alloc = hash_alloc; |
|
info.free = hash_free; |
|
info.key_offset = offsetof(struct match, pageid); |
|
|
|
cur = maxres = 0; |
cur = maxres = 0; |
*res = NULL; |
*res = NULL; |
|
|
Line 284 mansearch(const struct mansearch *search, |
|
Line 271 mansearch(const struct mansearch *search, |
|
SQL_BIND_INT64(db, s, j, ep->bits); |
SQL_BIND_INT64(db, s, j, ep->bits); |
} |
} |
|
|
memset(&htab, 0, sizeof(struct ohash)); |
mandoc_ohash_init(&htab, 4, offsetof(struct match, pageid)); |
ohash_init(&htab, 4, &info); |
|
|
|
/* |
/* |
* Hash each entry on its [unique] document identifier. |
* Hash each entry on its [unique] document identifier. |
Line 852 exprfree(struct expr *p) |
|
Line 838 exprfree(struct expr *p) |
|
free(p); |
free(p); |
p = pp; |
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); |
|
} |
} |