From 1cf41474327ca813976f622e8e0b73bb3841a44c Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Fri, 16 Dec 2011 12:06:35 +0000 Subject: Make the stored "cat"/"mdoc"/"man" strings just be c/d/a single-character bytes. This cuts down a little in index size and allows for cleaner extraction of information. --- apropos_db.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'apropos_db.c') diff --git a/apropos_db.c b/apropos_db.c index fd657558..0d2b0728 100644 --- a/apropos_db.c +++ b/apropos_db.c @@ -1,4 +1,4 @@ -/* $Id: apropos_db.c,v 1.23 2011/12/10 21:46:59 kristaps Exp $ */ +/* $Id: apropos_db.c,v 1.24 2011/12/16 12:06:35 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -365,6 +365,7 @@ index_read(const DBT *key, const DBT *val, int index, { size_t left; char *np, *cp; + char type; #define INDEX_BREAD(_dst) \ do { \ @@ -375,13 +376,23 @@ index_read(const DBT *key, const DBT *val, int index, cp = np + 1; \ } while (/* CONSTCOND */ 0) - left = val->size; - cp = (char *)val->data; + if (0 == (left = val->size)) + return(0); + cp = val->data; rec->res.rec = *(recno_t *)key->data; rec->res.volume = index; - INDEX_BREAD(rec->res.type); + if ('d' == (type = *cp++)) + rec->res.type = RESTYPE_MDOC; + else if ('a' == type) + rec->res.type = RESTYPE_MAN; + else if ('c' == type) + rec->res.type = RESTYPE_CAT; + else + return(0); + + left--; INDEX_BREAD(rec->res.file); INDEX_BREAD(rec->res.cat); INDEX_BREAD(rec->res.title); @@ -581,7 +592,6 @@ static void recfree(struct rec *rec) { - free(rec->res.type); free(rec->res.file); free(rec->res.cat); free(rec->res.title); -- cgit v1.2.3