From fd572be14f6bd623f1ed47f0f88f91aa94741b0b Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Fri, 7 Oct 2011 13:29:03 +0000 Subject: [PATCH] Lift hard-coded limit of results. --- apropos.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/apropos.c b/apropos.c index 6afd3ec8..2c293d02 100644 --- a/apropos.c +++ b/apropos.c @@ -1,4 +1,4 @@ -/* $Id: apropos.c,v 1.2 2011/10/07 13:22:33 kristaps Exp $ */ +/* $Id: apropos.c,v 1.3 2011/10/07 13:29:03 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -289,12 +289,13 @@ state_search(struct state *p, const struct opts *opts, char *q) recno_t rec; uint32_t fl; DBT key, val; - struct res res[MAXRESULTS]; + struct res *res; regex_t reg; regex_t *regp; char filebuf[10]; struct rec record; + res = NULL; len = 0; buf = NULL; bufsz = 0; @@ -341,10 +342,7 @@ state_search(struct state *p, const struct opts *opts, char *q) * Lastly, add it to the available records. */ - while (len < MAXRESULTS) { - if ((ch = (*p->db->seq)(p->db, &key, &val, dflag))) - break; - + while (0 == (ch = (*p->db->seq)(p->db, &key, &val, dflag))) { dflag = R_NEXT; /* @@ -411,6 +409,9 @@ state_search(struct state *p, const struct opts *opts, char *q) if (i < len) continue; + res = mandoc_realloc + (res, (len + 1) * sizeof(struct res)); + /* * Now we have our filename, keywords, types, and all * other necessary information. @@ -471,6 +472,7 @@ send: free(res[len].uri); } + free(res); free(buf); mchars_free(mc); -- 2.47.1