+#include "dict-p.h"
+
+static void dict_del_subtree (Dict dict, Dict_ptr ptr,
+ void *client,
+ int (*f)(const char *, void *))
+{
+ void *p = 0;
+ short *indxp;
+ int i, hi;
+
+ if (!ptr)
+ return;
+
+ dict_bf_readp (dict->dbf, ptr, &p);
+ indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
+ hi = DICT_nodir(p)-1;
+ for (i = 0; i <= hi; i++)
+ {
+ if (indxp[-i] > 0)
+ {
+ /* string (Dict_char *) DICT_EOS terminated */
+ /* unsigned char length of information */
+ /* char * information */
+ char *info = (char*)p + indxp[-i];
+ if (f)
+ (*f)(info + (dict_strlen((Dict_char*) info)+1)
+ *sizeof(Dict_char), client);
+ }
+ else
+ {
+ Dict_ptr subptr;
+
+ /* Dict_ptr subptr */
+ /* Dict_char sub char */
+ /* unsigned char length of information */
+ /* char * information */
+ char *info = (char*)p - indxp[-i];
+ memcpy (&subptr, info, sizeof(Dict_ptr));
+
+ if (info[sizeof(Dict_ptr)+sizeof(Dict_char)])
+ {
+ if (f)
+ (*f)(info+sizeof(Dict_ptr)+sizeof(Dict_char), client);
+ }
+ if (subptr)
+ {
+ dict_del_subtree (dict, subptr, client, f);
+
+ /* page may be gone. reread it .. */
+ dict_bf_readp (dict->dbf, ptr, &p);
+ indxp = (short*) ((char*) p+DICT_bsize(p)-sizeof(short));
+ }
+ }
+ }
+ DICT_backptr(p) = dict->head.freelist;
+ dict->head.freelist = ptr;
+ dict_bf_touch (dict->dbf, ptr);
+}