- if (subptr == 0)
- return 0;
- ptr = subptr;
- dict_bf_readp (dict->dbf, ptr, &p);
- mid = lo = 0;
- hi = DICT_nodir(p)-1;
- indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
- continue;
+ /* subptr may be 0 */
+ r = dict_del_string(dict, str, subptr, sub_flag, client, f);
+
+ /* recover */
+ dict_bf_readp(dict->dbf, ptr, &p);
+ indxp = (short*)
+ ((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 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)])
+ {
+ /* 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_bf_touch(dict->dbf, ptr);
+ r = 1;
+ }