int delete_drange(drange* p) { if(p==NULL) return 0; delete_option(p->options); free(p->name); free(p->description); free(p); return 1; }
Parser::~Parser() { map<string, option*>::iterator it; for(it = this->options.begin(); it != this->options.end(); ++it) { logger->log(DEBUG, "free key:%s", it->first.c_str()); delete_option(&(it->second)); } }
void done_domain_trees(void) { struct domain_tree *domain, *next; foreachsafe (domain, next, domain_trees) { delete_option(domain->tree); domain->tree = NULL; del_from_list(domain); mem_free(domain); }
int delete_option(curveoption* p) { if(p==NULL) return 0; delete_option(p->next); free(p->name); free(p->value); free(p->description); free(p->alarm); free(p); return 1; }
drange* merge_dranges(drange* a,drange* b) { if(a==NULL) return b; if(b==NULL) return a; if(a->name==NULL) a->name = b->name; else if(b->name!=NULL) free(b->name); if(a->description==NULL) a->description = b->description; else if(b->description!=NULL) free(b->description); if(a->options==NULL) a->options = b->options; else if(b->options!=NULL) delete_option(b->options); free(b); return a; }
static enum parse_error parse_unset(struct option *opt_tree, struct conf_parsing_state *state, struct string *mirror, int is_system_conf) { const unsigned char *optname_orig; size_t optname_len; unsigned char *optname_copy; skip_white(&state->pos); if (!*state->pos.look) return show_parse_error(state, ERROR_PARSE); /* Option name */ optname_orig = state->pos.look; while (is_option_name_char(*state->pos.look) || *state->pos.look == '.') state->pos.look++; optname_len = state->pos.look - optname_orig; optname_copy = memacpy(optname_orig, optname_len); if (!optname_copy) return show_parse_error(state, ERROR_NOMEM); { struct option *opt; opt = get_opt_rec_real(opt_tree, optname_copy); mem_free(optname_copy); optname_copy = NULL; if (!opt || (opt->flags & OPT_HIDDEN)) { /* The user wanted to delete the option, and * it has already been deleted; this is not an * error. This might happen if a version of * ELinks has a built-in URL rewriting rule, * the user disables it, and a later version * no longer has it. */ return ERROR_NONE; } if (!mirror) { /* loading a configuration file */ if (opt->flags & OPT_ALLOC) delete_option(opt); else mark_option_as_deleted(opt); } else if (is_system_conf) { /* scanning a file that will not be rewritten */ struct option *flagsite = indirect_option(opt); if (flagsite->flags & OPT_DELETED) flagsite->flags &= ~OPT_MUST_SAVE; else flagsite->flags |= OPT_MUST_SAVE; } else { /* rewriting a configuration file */ struct option *flagsite = indirect_option(opt); if (flagsite->flags & OPT_DELETED) { /* The "unset" command is already in the file, * and unlike with "set", there is no value * to be updated. */ } else if (option_types[opt->type].write) { /* Replace the "unset" command with a * "set" command. */ add_to_string(mirror, "set "); add_bytes_to_string(mirror, optname_orig, optname_len); add_to_string(mirror, " = "); option_types[opt->type].write(opt, mirror); state->mirrored = state->pos.look; } /* Remember that the option need not be * written to the end of the file. */ flagsite->flags &= ~OPT_MUST_SAVE; } } return ERROR_NONE; }