X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdialog-x.c;h=dc3ee71aac67c1e0b589e77b341f1a3e2acf6dd1;hb=41e784bb39d67f3906871511cb30805a71a6d6b3;hp=a61eee8e01d6cbfc90fe2224859a25ae7ccb307f;hpb=46f51e794ddb493a8a76ec2f3be00b41e3b0be22;p=chise%2Fxemacs-chise.git- diff --git a/src/dialog-x.c b/src/dialog-x.c index a61eee8..dc3ee71 100644 --- a/src/dialog-x.c +++ b/src/dialog-x.c @@ -44,7 +44,7 @@ maybe_run_dbox_text_callback (LWLIB_ID id) widget_value *wv; int got_some; wv = xmalloc_widget_value (); - wv->name = (char *) "value"; + wv->name = xstrdup ("value"); got_some = lw_get_some_values (id, wv); if (got_some) { @@ -56,10 +56,12 @@ maybe_run_dbox_text_callback (LWLIB_ID id) void *tmp = LISP_TO_VOID (list2 (text_field_callback, build_string (text_field_value))); popup_selection_callback (0, id, (XtPointer) tmp); - xfree (text_field_value); } } - free_widget_value (wv); + /* This code tried to optimize, newing/freeing. This is generally + unsafe so we will alwats strdup and always use + free_widget_value_tree. */ + free_widget_value_tree (wv); } static void @@ -144,7 +146,7 @@ dbox_descriptor_to_widget_value (Lisp_Object desc) wv_closure = make_opaque_ptr (kids); record_unwind_protect (widget_value_unwind, wv_closure); - prev->name = (char *) "message"; + prev->name = xstrdup ("message"); prev->value = xstrdup (name); prev->enabled = 1; @@ -166,7 +168,7 @@ dbox_descriptor_to_widget_value (Lisp_Object desc) gui_item = gui_parse_item_keywords (button); if (!button_item_to_widget_value (gui_item, wv, allow_text_p, 1)) { - free_widget_value (wv); + free_widget_value_tree (wv); continue; } @@ -178,8 +180,9 @@ dbox_descriptor_to_widget_value (Lisp_Object desc) else /* it's a button */ { allow_text_p = 0; /* only allow text field at the front */ - wv->value = xstrdup (wv->name); /* what a mess... */ - wv->name = (char *) button_names [n]; + if (wv->value) xfree (wv->value); + wv->value = wv->name; /* what a mess... */ + wv->name = xstrdup (button_names [n]); if (partition_seen) rbuttons++; @@ -202,7 +205,7 @@ dbox_descriptor_to_widget_value (Lisp_Object desc) widget_value *dbox; sprintf (tmp_dbox_name, "%c%dBR%d", type, lbuttons + rbuttons, rbuttons); dbox = xmalloc_widget_value (); - dbox->name = tmp_dbox_name; + dbox->name = xstrdup (tmp_dbox_name); dbox->contents = kids; /* No more need to free the half-filled-in structures. */