void delete_proplist(PropPtr p) { if (!p) return; delete_proplist(AVL_LF(p)); delete_proplist(PropDir(p)); delete_proplist(AVL_RT(p)); free_propnode(p); }
/** * Recursively deletes an entire proplist AVL with 'p' as the root, * and frees 'p' itself. * * @param p The proplist to delete. */ void delete_proplist(PropPtr p) { if (!p) return; delete_proplist(p->left); delete_proplist(PropDir(p)); delete_proplist(p->right); free_propnode(p); }
void unloadprops_with_prejudice(dbref obj) { PropPtr l; if ((l = DBFETCH(obj)->properties)) { /* if it has props, then dispose */ delete_proplist(l); DBFETCH(obj)->properties = NULL; } removeobj_ringqueue(obj); DBFETCH(obj)->propsmode = PROPS_UNLOADED; DBFETCH(obj)->propstime = 0; }
/* path is the name of the property to delete */ PropPtr propdir_delete_elem(PropPtr root, char *path) { PropPtr p; char *n; if (!root) return (NULL); while (*path && *path == PROPDIR_DELIMITER) path++; if (!*path) return (root); n = index(path, PROPDIR_DELIMITER); while (n && *n == PROPDIR_DELIMITER) *(n++) = '\0'; if (n && *n) { /* just another propdir in the path */ p = locate_prop(root, path); if (p && PropDir(p)) { /* yup, found the propdir */ SetPDir(p, propdir_delete_elem(PropDir(p), n)); if (!PropDir(p) && PropType(p) == PROP_DIRTYP) { root = delete_prop(&root, PropName(p)); } } /* return the updated root pntr */ return (root); } else { /* aha, we are finally to the property itself. */ p = locate_prop(root, path); if (p && PropDir(p)) { delete_proplist(PropDir(p)); } (void) delete_prop(&root, path); return (root); } }