From b97508e48a5cbaba4d89e647597ed65fab3466c7 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 19 Feb 2006 07:15:27 +0000 Subject: [PATCH] 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. --- src/bfu/hierbox.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bfu/hierbox.c b/src/bfu/hierbox.c index 297002df6..67887c601 100644 --- a/src/bfu/hierbox.c +++ b/src/bfu/hierbox.c @@ -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);