X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=dict%2Fdelete.c;h=d81c384666c361457f04e557feddc0e276ffdc55;hp=eb5e41c7622ec084383704df5005aebfe660a1dc;hb=3bb2fd863b1664f1ff71dadb540313f301ca234f;hpb=a66b7d79383ae700f3358731eecfe2aafed0e90d diff --git a/dict/delete.c b/dict/delete.c index eb5e41c..d81c384 100644 --- a/dict/delete.c +++ b/dict/delete.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1994-2010 Index Data + Copyright (C) 1994-2011 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 @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -207,19 +210,31 @@ static int dict_del_string(Dict dict, const Dict_char *str, Dict_ptr ptr, ((char*) p+DICT_bsize(p)-sizeof(short)); info = (char*)p - indxp[-mid]; + subptr = 0; /* avoid dict_del_subtree (end of function)*/ if (r == 2) - { /* subptr page is empty and already removed */ - hi = DICT_nodir(p)-1; - while (mid < hi) + { /* subptr page became empty and is removed */ + + /* see if this entry is a real one or if it just + serves as pointer to subptr */ + if (info[sizeof(Dict_ptr)+sizeof(Dict_char)]) { - indxp[-mid] = indxp[-mid-1]; - mid++; + /* this entry do exist, set subptr to 0 */ + memcpy(info, &subptr, sizeof(subptr)); + } + else + { + /* this entry ONLY points to subptr. remove it */ + hi = DICT_nodir(p)-1; + while (mid < hi) + { + indxp[-mid] = indxp[-mid-1]; + mid++; + } + (DICT_nodir(p))--; } - (DICT_nodir(p))--; dict_bf_touch(dict->dbf, ptr); r = 1; } - subptr = 0; /* prevent dict_del_subtree (below) */ } break; }