From 1209da2618a90d6a811311becdbe2126ffdaa0de Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 7 Dec 1995 11:48:55 +0000 Subject: [PATCH] Insert operation obeys DICT_type = 1 (slack in page). Function dict_open exists if page size or magic aren't right. --- dict/delete.c | 8 +++++++- dict/insert.c | 11 ++++++++++- dict/open.c | 20 ++++++++++---------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/dict/delete.c b/dict/delete.c index d65efaa..e5be225 100644 --- a/dict/delete.c +++ b/dict/delete.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: delete.c,v $ - * Revision 1.2 1995-12-06 17:48:30 adam + * Revision 1.3 1995-12-07 11:48:55 adam + * Insert operation obeys DICT_type = 1 (slack in page). + * Function dict_open exists if page size or magic aren't right. + * + * Revision 1.2 1995/12/06 17:48:30 adam * Bug fix: delete didn't work. * * Revision 1.1 1995/12/06 14:52:21 adam @@ -50,6 +54,7 @@ static int dict_del (Dict dict, const Dict_char *str) indxp[-mid] = indxp[-mid-1]; mid++; } + DICT_type(p) = 1; (DICT_nodir(p))--; dict_bf_touch (dict->dbf, ptr); return 1; @@ -75,6 +80,7 @@ static int dict_del (Dict dict, const Dict_char *str) if (info[sizeof(Dict_ptr)+sizeof(Dict_char)]) { info[sizeof(Dict_ptr)+sizeof(Dict_char)] = 0; + DICT_type(p) = 1; dict_bf_touch (dict->dbf, ptr); return 1; } diff --git a/dict/insert.c b/dict/insert.c index 4a0007f..396640a 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: insert.c,v $ - * Revision 1.13 1995-11-28 09:06:37 adam + * Revision 1.14 1995-12-07 11:48:56 adam + * Insert operation obeys DICT_type = 1 (slack in page). + * Function dict_open exists if page size or magic aren't right. + * + * Revision 1.13 1995/11/28 09:06:37 adam * Fixed potential dangling pointer. * * Revision 1.12 1995/09/06 10:34:44 adam @@ -411,6 +415,11 @@ static int dict_ins (Dict dict, const Dict_char *str, if (DICT_size(p)+slen+userlen >= DICT_pagesize(dict) - (1+DICT_nodir(p))*sizeof(short)) /* overflow? */ { + if (DICT_type(p)) + { + clean_page (dict, ptr, p, NULL, 0, NULL); + return dict_ins (dict, str, ptr, userlen, userinfo); + } split_page (dict, ptr, p); return dict_ins (dict, str, ptr, userlen, userinfo); } diff --git a/dict/open.c b/dict/open.c index e20f2f5..95c86ca 100644 --- a/dict/open.c +++ b/dict/open.c @@ -4,7 +4,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: open.c,v $ - * Revision 1.7 1995-09-04 12:33:32 adam + * Revision 1.8 1995-12-07 11:48:56 adam + * Insert operation obeys DICT_type = 1 (slack in page). + * Function dict_open exists if page size or magic aren't right. + * + * Revision 1.7 1995/09/04 12:33:32 adam * Various cleanup. YAZ util used instead. * * Revision 1.6 1994/10/05 12:16:52 adam @@ -47,11 +51,11 @@ Dict dict_open (const char *name, int cache, int rw) page_size = atoi (res_get_def (common_resource, resource_str, DICT_DEFAULT_PAGESIZE)); - if (page_size < 1024) + if (page_size < 2048) { - logf (LOG_WARN, "Resource %s was too small. Set to 1024", + logf (LOG_WARN, "Resource %s was too small. Set to 2048", resource_str); - page_size = 1024; + page_size = 2048; } dict->dbf = dict_bf_open (name, page_size, cache, rw); dict->rw = rw; @@ -85,17 +89,13 @@ Dict dict_open (const char *name, int cache, int rw) if (strcmp (dh->magic_str, DICT_MAGIC)) { logf (LOG_WARN, "Bad magic of `%s'", name); - dict_bf_close (dict->dbf); - xfree (dict); - return NULL; + exit (1); } if (dh->page_size != page_size) { logf (LOG_WARN, "Resource %s is %d and pagesize of `%s' is %d", resource_str, page_size, name, dh->page_size); - dict_bf_close (dict->dbf); - xfree (dict); - return NULL; + exit (1); } memcpy (&dict->head, dh, sizeof(*dh)); } -- 1.7.10.4