1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Simplify query_delete_selected_item

Check whether the item can be deleted before allocating the context so
as to save a free in the case that the item cannot be deleted.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-02-19 07:15:27 +00:00 committed by Miciah Dashiel Butler Masters
parent e9799a2265
commit b97508e48a

View File

@ -733,20 +733,19 @@ query_delete_selected_item(void *context_)
assert(item);
context = init_listbox_context(box, term, item, NULL);
if (!context) return EVENT_PROCESSED;
context->widget_data = oldcontext->widget_data;
delete = ops->can_delete(item)
? DELETE_LOCKED : DELETE_IMPOSSIBLE;
if (delete == DELETE_IMPOSSIBLE || ops->is_used(item)) {
print_delete_error(item, term, ops, delete);
mem_free(context);
return EVENT_PROCESSED;
}
context = init_listbox_context(box, term, item, NULL);
if (!context) return EVENT_PROCESSED;
context->widget_data = oldcontext->widget_data;
text = ops->get_text(item, term);
if (!text) {
mem_free(context);