aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-01 23:46:26 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-01 23:46:26 +0000
commit80244c48e0ba678ad998cda0739a4d5dc399ac10 (patch)
treeedaa37753f483d24878eb7c9b215608e75387e9c /mandocdb.c
parentfe601f87b54c0e4c28459c08fb59627e673e2094 (diff)
downloadmandoc-80244c48e0ba678ad998cda0739a4d5dc399ac10.tar.gz
mandoc-80244c48e0ba678ad998cda0739a4d5dc399ac10.tar.zst
mandoc-80244c48e0ba678ad998cda0739a4d5dc399ac10.zip
In apropos_db.c, move all btree reading (and safety checks) into the
btree_read() function. Also, add a forgotten free() for the type of grokked record. Then in both mandocdb.c and apropos_db.c, make the "rec" field of the btree by in network-order.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 8a3409ae..1df2a00d 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.18 2011/12/01 21:05:49 kristaps Exp $ */
+/* $Id: mandocdb.c,v 1.19 2011/12/01 23:46:26 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,6 +33,8 @@
#include <string.h>
#include <unistd.h>
+#include <arpa/inet.h>
+
#ifdef __linux__
# include <db_185.h>
#else
@@ -626,15 +628,13 @@ index_merge(const struct of *of, struct mparse *mp,
* into the database.
*/
- vbuf.rec = rec;
+ vbuf.rec = htonl(rec);
seq = R_FIRST;
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) {
seq = R_NEXT;
-
vbuf.mask = *(uint64_t *)val.data;
val.size = sizeof(struct db_val);
val.data = &vbuf;
-
dbt_put(db, dbf, &key, &val);
}
if (ch < 0) {
@@ -732,7 +732,7 @@ index_prune(const struct of *ofile, DB *db, const char *dbf,
break;
vbuf = val.data;
- if (*maxrec != vbuf->rec)
+ if (*maxrec != ntohl(vbuf->rec))
continue;
if ((ch = (*db->del)(db, &key, R_CURSOR)) < 0)