X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=dict%2Finsert.c;h=ab7613f89a01171aa7fe7bcb251529813b3154b6;hb=d5170943ca365ace791c3254db15cc852df56d6b;hp=33392b90fd501ac312b570c0104deacd304976c7;hpb=4478d785b7769691261005c98063b98a5a5971b3;p=idzebra-moved-to-github.git diff --git a/dict/insert.c b/dict/insert.c index 33392b9..ab7613f 100644 --- a/dict/insert.c +++ b/dict/insert.c @@ -1,8 +1,5 @@ -/* $Id: insert.c,v 1.27 2006-08-14 10:40:09 adam Exp $ - Copyright (C) 1995-2006 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1995-2008 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -74,6 +71,7 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p) Dict_char prev_char = 0; int best_no = -1, no_current = 1; + dict->no_split++; /* determine splitting char... */ indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short)); for (i = DICT_nodir (p); --i >= 0; --indxp) @@ -105,8 +103,7 @@ static int split_page (Dict dict, Dict_ptr ptr, void *p) } } } - if (best_no < 0) /* we didn't find any tail string entry at all! */ - return -1; + assert(best_no >= 0); /* we didn't find any tail string entry at all! */ j = best_indxp - (short*) p; subptr = new_page (dict, ptr, &subp); @@ -344,7 +341,7 @@ static int dict_ins (Dict dict, const Dict_char *str, if (split_page (dict, ptr, p)) { yaz_log (YLOG_FATAL, "Unable to split page %d\n", ptr); - abort (); + assert(0); } return dict_ins (dict, str-1, ptr, userlen, userinfo); } @@ -437,13 +434,15 @@ static int dict_ins (Dict dict, const Dict_char *str, int dict_insert (Dict dict, const char *str, int userlen, void *userinfo) { + if (!dict->rw) + return -1; + dict->no_insert++; if (!dict->head.root) { void *p; - if (dict->rw) - dict->head.root = new_page (dict, 0, &p); + dict->head.root = new_page (dict, 0, &p); if (!dict->head.root) - return 0; + return -1; } return dict_ins (dict, (const Dict_char *) str, dict->head.root, userlen, userinfo);