emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r117239: Use common memory management functions for


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r117239: Use common memory management functions for lwlib and refactor users.
Date: Mon, 02 Jun 2014 18:02:17 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117239
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Mon 2014-06-02 22:01:21 +0400
message:
  Use common memory management functions for lwlib and refactor users.
  * lwlib/lwlib.h (widget_value): Do not maintain a free list any more.
  (malloc_widget_value, free_widget_value): Remove prototypes.
  * lwlib/lwlib.c (malloc_widget_value, free_widget_value):
  (widget_value_free_list, malloc_cpt): Remove.
  (free_widget_value_tree, copy_widget_value_tree): Adjust users.
  * src/menu.h (xmalloc_widget_value): Replaced by ...
  (make_widget_value): ... new prototype.
  * src/menu.c (xmalloc_widget_value): Replaced by ...
  (make_widget_value): ... new function.
  (free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
  * src/gtkutil.c (malloc_widget_value, free_widget_value):
  (widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
  * src/keyboard.h (enum button_type, struct _widget_value):
  * src/gtkutil.h, src/nsgui.h, src/w32gui.h (malloc_widget_value):
  (free_widget_value): Likewise.
  * src/nsmenu.m (ns_update_menubar, ns_menu_show):
  * src/w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
  * src/xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
  * src/xterm.h (XtParent) [USE_GTK]: Remove unused macro.
modified:
  lwlib/ChangeLog                changelog-20091113204419-o5vbwnq5f7feedwu-1447
  lwlib/lwlib.c                  lwlib.c-20091113204419-o5vbwnq5f7feedwu-672
  lwlib/lwlib.h                  lwlib.h-20091113204419-o5vbwnq5f7feedwu-673
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/gtkutil.c                  gtkutil.c-20091113204419-o5vbwnq5f7feedwu-2527
  src/gtkutil.h                  gtkutil.h-20091113204419-o5vbwnq5f7feedwu-2528
  src/keyboard.h                 keyboard.h-20091113204419-o5vbwnq5f7feedwu-450
  src/menu.c                     menu.c-20091113204419-o5vbwnq5f7feedwu-8676
  src/menu.h                     menu.h-20091113204419-o5vbwnq5f7feedwu-8702
  src/nsgui.h                    nsgui.h-20091113204419-o5vbwnq5f7feedwu-8742
  src/nsmenu.m                   nsmenu.m-20091113204419-o5vbwnq5f7feedwu-8744
  src/w32gui.h                   w32gui.h-20091113204419-o5vbwnq5f7feedwu-946
  src/w32menu.c                  w32menu.c-20091113204419-o5vbwnq5f7feedwu-947
  src/xmenu.c                    xmenu.c-20091113204419-o5vbwnq5f7feedwu-161
  src/xterm.h                    xterm.h-20091113204419-o5vbwnq5f7feedwu-228
=== modified file 'lwlib/ChangeLog'
--- a/lwlib/ChangeLog   2014-05-30 13:22:29 +0000
+++ b/lwlib/ChangeLog   2014-06-02 18:01:21 +0000
@@ -1,3 +1,12 @@
+2014-06-02  Dmitry Antipov  <address@hidden>
+
+       Use common memory management functions for widgets.
+       * lwlib.h (widget_value): Do not maintain a free list any more.
+       (malloc_widget_value, free_widget_value): Remove prototypes.
+       * lwlib.c (malloc_widget_value, free_widget_value):
+       (widget_value_free_list, malloc_cpt): Remove.
+       (free_widget_value_tree, copy_widget_value_tree): Adjust users.
+
 2014-05-30  Dmitry Antipov  <address@hidden>
 
        Use common string allocation and freeing functions where applicable.

=== modified file 'lwlib/lwlib.c'
--- a/lwlib/lwlib.c     2014-05-30 13:22:29 +0000
+++ b/lwlib/lwlib.c     2014-06-02 18:01:21 +0000
@@ -99,51 +99,6 @@
 static Boolean get_one_value (widget_instance *, widget_value *);
 static void show_one_widget_busy (Widget, Boolean);
 
-static widget_value *widget_value_free_list = 0;
-static int malloc_cpt = 0;
-
-widget_value *
-malloc_widget_value (void)
-{
-  widget_value *wv;
-  if (widget_value_free_list)
-    {
-      wv = widget_value_free_list;
-      widget_value_free_list = wv->free_list;
-      wv->free_list = 0;
-    }
-  else
-    {
-      wv = (widget_value *) xmalloc (sizeof (widget_value));
-      malloc_cpt++;
-    }
-  memset ((void*) wv, 0, sizeof (widget_value));
-  return wv;
-}
-
-/* this is analogous to free().  It frees only what was allocated
-   by malloc_widget_value(), and no substructures.
- */
-void
-free_widget_value (widget_value *wv)
-{
-  if (wv->free_list)
-    abort ();
-
-  if (malloc_cpt > 25)
-    {
-      /* When the number of already allocated cells is too big,
-        We free it.  */
-      xfree (wv);
-      malloc_cpt--;
-    }
-  else
-    {
-      wv->free_list = widget_value_free_list;
-      widget_value_free_list = wv;
-    }
-}
-
 static void
 free_widget_value_tree (widget_value *wv)
 {
@@ -172,7 +127,7 @@
       free_widget_value_tree (wv->next);
       wv->next = (widget_value *) 0xDEADBEEF;
     }
-  free_widget_value (wv);
+  xfree (wv);
 }
 
 static widget_value *
@@ -185,7 +140,8 @@
   if (val == (widget_value *) 1)
     return val;
 
-  copy = malloc_widget_value ();
+  copy = xmalloc (sizeof (widget_value));
+  copy->lname = copy->lkey = Qnil;
   copy->name = xstrdup (val->name);
   copy->value = val->value ? xstrdup (val->value) : NULL;
   copy->key = val->key ? xstrdup (val->key) : NULL;

=== modified file 'lwlib/lwlib.h'
--- a/lwlib/lwlib.h     2014-01-01 07:43:34 +0000
+++ b/lwlib/lwlib.h     2014-06-02 18:01:21 +0000
@@ -119,11 +119,6 @@
   /* tell us if we should free the toolkit data slot when freeing the
      widget_value itself. */
   Boolean free_toolkit_data;
-
-  /* we resource the widget_value structures; this points to the next
-     one on the free list if this one has been deallocated.
-   */
-  struct _widget_value *free_list;
 } widget_value;
 
 
@@ -153,8 +148,6 @@
 Boolean lw_get_some_values (LWLIB_ID id, widget_value* val);
 void lw_pop_up_all_widgets (LWLIB_ID id);
 void lw_pop_down_all_widgets (LWLIB_ID id);
-widget_value *malloc_widget_value (void);
-void free_widget_value (widget_value *);
 void lw_popup_menu (Widget, XEvent *);
 
 /* Toolkit independent way of focusing on a Widget at the Xt level. */

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-06-02 17:55:38 +0000
+++ b/src/ChangeLog     2014-06-02 18:01:21 +0000
@@ -1,5 +1,23 @@
 2014-06-02  Dmitry Antipov  <address@hidden>
 
+       Adjust to match recent lwlib changes.
+       * menu.h (xmalloc_widget_value): Replaced by ...
+       (make_widget_value): ... new prototype.
+       * menu.c (xmalloc_widget_value): Replaced by ...
+       (make_widget_value): ... new function.
+       (free_menubar_widget_value_tree, digest_single_submenu): Adjust users.
+       * gtkutil.c (malloc_widget_value, free_widget_value):
+       (widget_value_free_list, malloc_cpt): Remove old lwlib-compatible code.
+       * keyboard.h (enum button_type, struct _widget_value):
+       * gtkutil.h, nsgui.h, w32gui.h (malloc_widget_value, free_widget_value):
+       Likewise.
+       * nsmenu.m (ns_update_menubar, ns_menu_show):
+       * w32menu.c (set_frame_menubar, w32_menu_show, w32_dialog_show):
+       * xmenu.c (set_frame_menubar, xmenu_show, x_dialog_show): Adjust users.
+       * xterm.h (XtParent) [USE_GTK]: Remove unused macro.
+
+2014-06-02  Dmitry Antipov  <address@hidden>
+
        * image.c (x_query_frame_background_color)
        [HAVE_PNG || HAVE_NS || HAVE_IMAGEMAGICK || HAVE_RSVG]:
        Fix --enable-gcc-warnings compilation without image libraries.

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2014-02-28 21:45:34 +0000
+++ b/src/gtkutil.c     2014-06-02 18:01:21 +0000
@@ -221,57 +221,6 @@
 /***********************************************************************
                       Utility functions
  ***********************************************************************/
-/* The next two variables and functions are taken from lwlib.  */
-static widget_value *widget_value_free_list;
-static int malloc_cpt;
-
-/* Allocate a widget_value structure, either by taking one from the
-   widget_value_free_list or by malloc:ing a new one.
-
-   Return a pointer to the allocated structure.  */
-
-widget_value *
-malloc_widget_value (void)
-{
-  widget_value *wv;
-  if (widget_value_free_list)
-    {
-      wv = widget_value_free_list;
-      widget_value_free_list = wv->free_list;
-      wv->free_list = 0;
-    }
-  else
-    {
-      wv = xmalloc (sizeof *wv);
-      malloc_cpt++;
-    }
-  memset (wv, 0, sizeof (widget_value));
-  return wv;
-}
-
-/* This is analogous to free.  It frees only what was allocated
-   by malloc_widget_value, and no substructures.  */
-
-void
-free_widget_value (widget_value *wv)
-{
-  if (wv->free_list)
-    emacs_abort ();
-
-  if (malloc_cpt > 25)
-    {
-      /* When the number of already allocated cells is too big,
-        We free it.  */
-      xfree (wv);
-      malloc_cpt--;
-    }
-  else
-    {
-      wv->free_list = widget_value_free_list;
-      widget_value_free_list = wv;
-    }
-}
-
 
 /* Create and return the cursor to be used for popup menus and
    scroll bars on display DPY.  */

=== modified file 'src/gtkutil.h'
--- a/src/gtkutil.h     2014-05-22 16:40:35 +0000
+++ b/src/gtkutil.h     2014-06-02 18:01:21 +0000
@@ -24,6 +24,7 @@
 #ifdef USE_GTK
 
 #include <gtk/gtk.h>
+#include "../lwlib/lwlib.h"
 #include "frame.h"
 #include "xterm.h"
 
@@ -74,9 +75,6 @@
 
 } xg_menu_item_cb_data;
 
-extern struct _widget_value *malloc_widget_value (void) ATTRIBUTE_MALLOC;
-extern void free_widget_value (struct _widget_value *);
-
 extern bool xg_uses_old_file_dialog (void) ATTRIBUTE_CONST;
 
 extern char *xg_get_file_name (struct frame *f,

=== modified file 'src/keyboard.h'
--- a/src/keyboard.h    2014-01-01 07:43:34 +0000
+++ b/src/keyboard.h    2014-06-02 18:01:21 +0000
@@ -354,57 +354,6 @@
 #define ENCODE_MENU_STRING(str) (str)
 #endif
 
-#if defined (HAVE_NS) || defined (HAVE_NTGUI) || defined (USE_GTK)
-
-/* Definitions copied from lwlib.h */
-
-enum button_type
-{
-  BUTTON_TYPE_NONE,
-  BUTTON_TYPE_TOGGLE,
-  BUTTON_TYPE_RADIO
-};
-
-/* This structure is based on the one in ../lwlib/lwlib.h, with unused portions
-   removed.  No term uses these. */
-typedef struct _widget_value
-{
-  /* name of widget */
-  Lisp_Object   lname;
-  const char*  name;
-  /* value (meaning depend on widget type) */
-  const char*  value;
-  /* keyboard equivalent. no implications for XtTranslations */
-  Lisp_Object   lkey;
-  const char*  key;
-  /* Help string or nil if none.
-     GC finds this string through the frame's menu_bar_vector
-     or through menu_items.  */
-  Lisp_Object  help;
-  /* true if enabled */
-  unsigned char        enabled;
-  /* true if selected */
-  unsigned char selected;
-  /* The type of a button.  */
-  enum button_type button_type;
-#if defined (HAVE_NTGUI)
-  /* true if menu title */
-  unsigned char title;
-#endif
-  /* Contents of the sub-widgets, also selected slot for checkbox */
-  struct _widget_value*        contents;
-  /* data passed to callback */
-  void *call_data;
-  /* next one in the list */
-  struct _widget_value*        next;
-#ifdef USE_GTK
-  struct _widget_value *free_list;
-#endif
-} widget_value;
-
-#endif /* HAVE_NS || HAVE_NTGUI */
-
-
 /* Macros for dealing with lispy events.  */
 
 /* True if EVENT has data fields describing it (i.e. a mouse click).  */

=== modified file 'src/menu.c'
--- a/src/menu.c        2014-04-16 13:27:28 +0000
+++ b/src/menu.c        2014-06-02 18:01:21 +0000
@@ -576,21 +576,26 @@
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || 
defined (HAVE_NTGUI)
 
-/* Allocate a widget_value, blocking input.  */
+/* Allocate and basically initialize widget_value, blocking input.  */
 
 widget_value *
-xmalloc_widget_value (void)
+make_widget_value (const char *name, char *value,
+                  bool enabled, Lisp_Object help)
 {
-  widget_value *value;
+  widget_value *wv;
 
   block_input ();
-  value = malloc_widget_value ();
+  wv = xzalloc (sizeof (widget_value));
   unblock_input ();
 
-  return value;
+  wv->name = (char *) name;
+  wv->value = value;
+  wv->enabled = enabled;
+  wv->help = help;
+  return wv;
 }
 
-/* This recursively calls free_widget_value on the tree of widgets.
+/* This recursively calls xfree on the tree of widgets.
    It must free all data that was malloc'ed for these widget_values.
    In Emacs, many slots are pointers into the data of Lisp_Strings, and
    must be left alone.  */
@@ -613,7 +618,7 @@
       wv->next = (widget_value *) 0xDEADBEEF;
     }
   block_input ();
-  free_widget_value (wv);
+  xfree (wv);
   unblock_input ();
 }
 
@@ -632,12 +637,8 @@
   struct frame *f = XFRAME (Vmenu_updating_frame);
 
   submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
-  wv = xmalloc_widget_value ();
-  wv->name = "menu";
-  wv->value = 0;
-  wv->enabled = 1;
+  wv = make_widget_value ("menu", NULL, true, Qnil);
   wv->button_type = BUTTON_TYPE_NONE;
-  wv->help = Qnil;
   first_wv = wv;
   save_wv = 0;
   prev_wv = 0;
@@ -721,17 +722,14 @@
             with its items as a submenu beneath it.  */
          if (strcmp (pane_string, ""))
            {
-             wv = xmalloc_widget_value ();
+             /* Set value to 1 so update_submenu_strings can handle '@'.  */
+             wv = make_widget_value (NULL, (char *) 1, true, Qnil);
              if (save_wv)
                save_wv->next = wv;
              else
                first_wv->contents = wv;
              wv->lname = pane_name;
-              /* Set value to 1 so update_submenu_strings can handle '@'  */
-             wv->value = (char *)1;
-             wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
-             wv->help = Qnil;
              save_wv = wv;
            }
          else
@@ -805,7 +803,8 @@
 #endif
            }
 
-         wv = xmalloc_widget_value ();
+         wv = make_widget_value (NULL, NULL, !NILP (enable),
+                                 STRINGP (help) ? help : Qnil);
          if (prev_wv)
            prev_wv->next = wv;
          else
@@ -814,11 +813,9 @@
          wv->lname = item_name;
          if (!NILP (descrip))
            wv->lkey = descrip;
-         wv->value = 0;
          /* The intptr_t cast avoids a warning.  There's no problem
             as long as pointers have enough bits to hold small integers.  */
          wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
-         wv->enabled = !NILP (enable);
 
          if (NILP (type))
            wv->button_type = BUTTON_TYPE_NONE;
@@ -830,10 +827,6 @@
            emacs_abort ();
 
          wv->selected = !NILP (selected);
-         if (! STRINGP (help))
-           help = Qnil;
-
-         wv->help = help;
 
          prev_wv = wv;
 
@@ -846,7 +839,7 @@
   if (top_level_items && first_wv->contents && first_wv->contents->next == 0)
     {
       wv = first_wv->contents;
-      free_widget_value (first_wv);
+      xfree (first_wv);
       return wv;
     }
 

=== modified file 'src/menu.h'
--- a/src/menu.h        2014-02-04 16:13:51 +0000
+++ b/src/menu.h        2014-06-02 18:01:21 +0000
@@ -20,6 +20,10 @@
 #define MENU_H
 
 #include "systime.h" /* for Time */
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
+  || defined (HAVE_NS)
+#include "../lwlib/lwlib.h" /* for widget_value */
+#endif
 
 #ifdef HAVE_NTGUI
 extern Lisp_Object Qunsupported__w32_dialog;
@@ -41,7 +45,7 @@
 extern void update_submenu_strings (widget_value *);
 extern void find_and_call_menu_selection (struct frame *, int,
                                           Lisp_Object, void *);
-extern widget_value *xmalloc_widget_value (void);
+extern widget_value *make_widget_value (const char *, char *, bool, 
Lisp_Object);
 extern widget_value *digest_single_submenu (int, int, bool);
 #endif
 

=== modified file 'src/nsgui.h'
--- a/src/nsgui.h       2014-01-01 07:43:34 +0000
+++ b/src/nsgui.h       2014-06-02 18:01:21 +0000
@@ -48,11 +48,6 @@
 #undef _GL_VERIFY_H
 #include <verify.h>
 
-/* menu-related */
-#define free_widget_value(wv) xfree (wv)
-#define malloc_widget_value() ((widget_value *) memset (xmalloc \
-    (sizeof (widget_value)), 0, sizeof (widget_value)))
-
 /* Emulate XCharStruct.  */
 typedef struct _XCharStruct
 {

=== modified file 'src/nsmenu.m'
--- a/src/nsmenu.m      2014-04-07 20:54:16 +0000
+++ b/src/nsmenu.m      2014-06-02 18:01:21 +0000
@@ -266,12 +266,8 @@
 
       /* parse stage 2: insert into lucid 'widget_value' structures
          [comments in other terms say not to evaluate lisp code here] */
-      wv = xmalloc_widget_value ();
-      wv->name = "menubar";
-      wv->value = 0;
-      wv->enabled = 1;
+      wv = make_widget_value ("menubar", NULL, true, Qnil);
       wv->button_type = BUTTON_TYPE_NONE;
-      wv->help = Qnil;
       first_wv = wv;
 
       for (i = 0; i < 4*n; i += 4)
@@ -378,12 +374,8 @@
       int n;
       Lisp_Object string;
 
-      wv = xmalloc_widget_value ();
-      wv->name = "menubar";
-      wv->value = 0;
-      wv->enabled = 1;
+      wv = make_widget_value ("menubar", NULL, true, Qnil);
       wv->button_type = BUTTON_TYPE_NONE;
-      wv->help = Qnil;
       first_wv = wv;
 
       /* Make widget-value tree w/ just the top level menu bar strings */
@@ -439,12 +431,8 @@
            memcpy (previous_strings[i/4], SDATA (string),
                     min (10, SBYTES (string) + 1));
 
-         wv = xmalloc_widget_value ();
-         wv->name = SSDATA (string);
-         wv->value = 0;
-         wv->enabled = 1;
+         wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
          wv->button_type = BUTTON_TYPE_NONE;
-         wv->help = Qnil;
          wv->call_data = (void *) (intptr_t) (-1);
 
 #ifdef NS_IMPL_COCOA
@@ -838,12 +826,8 @@
   p.x = x; p.y = y;
 
   /* now parse stage 2 as in ns_update_menubar */
-  wv = xmalloc_widget_value ();
-  wv->name = "contextmenu";
-  wv->value = 0;
-  wv->enabled = 1;
+  wv = make_widget_value ("contextmenu", NULL, true, Qnil);
   wv->button_type = BUTTON_TYPE_NONE;
-  wv->help = Qnil;
   first_wv = wv;
 
 #if 0
@@ -914,18 +898,14 @@
             with its items as a submenu beneath it.  */
          if (!keymaps && strcmp (pane_string, ""))
            {
-             wv = xmalloc_widget_value ();
+             wv = make_widget_value (pane_string, NULL, true, Qnil);
              if (save_wv)
                save_wv->next = wv;
              else
                first_wv->contents = wv;
-             wv->name = pane_string;
              if (keymaps && !NILP (prefix))
                wv->name++;
-             wv->value = 0;
-             wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
-             wv->help = Qnil;
              save_wv = wv;
              prev_wv = 0;
            }
@@ -963,20 +943,18 @@
            }
 #endif /* not HAVE_MULTILINGUAL_MENU */
 
-         wv = xmalloc_widget_value ();
+         wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
+                                 STRINGP (help) ? help : Qnil);
          if (prev_wv)
            prev_wv->next = wv;
          else
            save_wv->contents = wv;
-         wv->name = SSDATA (item_name);
          if (!NILP (descrip))
            wv->key = SSDATA (descrip);
-         wv->value = 0;
          /* If this item has a null value,
             make the call_data null so that it won't display a box
             when the mouse is on it.  */
          wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
-         wv->enabled = !NILP (enable);
 
          if (NILP (type))
            wv->button_type = BUTTON_TYPE_NONE;
@@ -989,11 +967,6 @@
 
          wv->selected = !NILP (selected);
 
-          if (! STRINGP (help))
-           help = Qnil;
-
-         wv->help = help;
-
          prev_wv = wv;
 
          i += MENU_ITEMS_ITEM_LENGTH;
@@ -1004,24 +977,19 @@
 
   if (!NILP (title))
     {
-      widget_value *wv_title = xmalloc_widget_value ();
-      widget_value *wv_sep = xmalloc_widget_value ();
+      widget_value *wv_title;
+      widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
 
       /* Maybe replace this separator with a bitmap or owner-draw item
         so that it looks better.  Having two separators looks odd.  */
-      wv_sep->name = "--";
       wv_sep->next = first_wv->contents;
-      wv_sep->help = Qnil;
 
 #ifndef HAVE_MULTILINGUAL_MENU
       if (STRING_MULTIBYTE (title))
        title = ENCODE_MENU_STRING (title);
 #endif
-
-      wv_title->name = SSDATA (title);
-      wv_title->enabled = NO;
+      wv_title = make_widget_value (SSDATA (title), NULL, false, Qnil);
       wv_title->button_type = BUTTON_TYPE_NONE;
-      wv_title->help = Qnil;
       wv_title->next = wv_sep;
       first_wv->contents = wv_title;
     }

=== modified file 'src/w32gui.h'
--- a/src/w32gui.h      2014-01-01 07:43:34 +0000
+++ b/src/w32gui.h      2014-06-02 18:01:21 +0000
@@ -22,14 +22,11 @@
 
 #include "systime.h" /* for Time */
 
-/* Local memory management for menus.  */
+/* FIXME: old local memory management for menus.  */
 #define local_heap (GetProcessHeap ())
 #define local_alloc(n) (HeapAlloc (local_heap, HEAP_ZERO_MEMORY, (n)))
 #define local_free(p) (HeapFree (local_heap, 0, ((LPVOID) (p))))
 
-#define malloc_widget_value() ((widget_value *) local_alloc (sizeof 
(widget_value)))
-#define free_widget_value(wv) (local_free ((wv)))
-
 /* Emulate X GC's by keeping color and font info in a structure.  */
 typedef struct _XGCValues
 {

=== modified file 'src/w32menu.c'
--- a/src/w32menu.c     2014-05-29 17:16:00 +0000
+++ b/src/w32menu.c     2014-06-02 18:01:21 +0000
@@ -376,12 +376,8 @@
       /* Convert menu_items into widget_value trees
         to display the menu.  This cannot evaluate Lisp code.  */
 
-      wv = xmalloc_widget_value ();
-      wv->name = "menubar";
-      wv->value = 0;
-      wv->enabled = 1;
+      wv = make_widget_value ("menubar", NULL, true, Qnil);
       wv->button_type = BUTTON_TYPE_NONE;
-      wv->help = Qnil;
       first_wv = wv;
 
       for (i = 0; i < last_i; i += 4)
@@ -444,12 +440,8 @@
       /* Make a widget-value tree containing
         just the top level menu bar strings.  */
 
-      wv = xmalloc_widget_value ();
-      wv->name = "menubar";
-      wv->value = 0;
-      wv->enabled = 1;
+      wv = make_widget_value ("menubar", NULL, true, Qnil);
       wv->button_type = BUTTON_TYPE_NONE;
-      wv->help = Qnil;
       first_wv = wv;
 
       items = FRAME_MENU_BAR_ITEMS (f);
@@ -461,12 +453,8 @@
          if (NILP (string))
            break;
 
-         wv = xmalloc_widget_value ();
-         wv->name = SSDATA (string);
-         wv->value = 0;
-         wv->enabled = 1;
+         wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
          wv->button_type = BUTTON_TYPE_NONE;
-         wv->help = Qnil;
          /* This prevents lwlib from assuming this
             menu item is really supposed to be empty.  */
          /* The EMACS_INT cast avoids a warning.
@@ -600,12 +588,8 @@
 
   /* Create a tree of widget_value objects
      representing the panes and their items.  */
-  wv = xmalloc_widget_value ();
-  wv->name = "menu";
-  wv->value = 0;
-  wv->enabled = 1;
+  wv = make_widget_value ("menu", NULL, true, Qnil);
   wv->button_type = BUTTON_TYPE_NONE;
-  wv->help = Qnil;
   first_wv = wv;
   first_pane = 1;
 
@@ -665,18 +649,14 @@
             with its items as a submenu beneath it.  */
          if (!keymaps && strcmp (pane_string, ""))
            {
-             wv = xmalloc_widget_value ();
+             wv = make_widget_value (pane_string, NULL, true, Qnil);
              if (save_wv)
                save_wv->next = wv;
              else
                first_wv->contents = wv;
-             wv->name = pane_string;
              if (keymaps && !NILP (prefix))
                wv->name++;
-             wv->value = 0;
-             wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
-             wv->help = Qnil;
              save_wv = wv;
              prev_wv = 0;
            }
@@ -717,19 +697,17 @@
              ASET (menu_items, i + MENU_ITEMS_ITEM_EQUIV_KEY, descrip);
            }
 
-         wv = xmalloc_widget_value ();
+         wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enabled),
+                                 STRINGP (help) ? help : Qnil);
          if (prev_wv)
            prev_wv->next = wv;
          else
            save_wv->contents = wv;
-         wv->name = SSDATA (item_name);
          if (!NILP (descrip))
            wv->key = SSDATA (descrip);
-         wv->value = 0;
          /* Use the contents index as call_data, since we are
              restricted to 16-bits.  */
          wv->call_data = !NILP (def) ? (void *) (EMACS_INT) i : 0;
-         wv->enabled = !NILP (enable);
 
          if (NILP (type))
            wv->button_type = BUTTON_TYPE_NONE;
@@ -742,11 +720,6 @@
 
          wv->selected = !NILP (selected);
 
-          if (!STRINGP (help))
-           help = Qnil;
-
-         wv->help = help;
-
          prev_wv = wv;
 
          i += MENU_ITEMS_ITEM_LENGTH;
@@ -756,25 +729,21 @@
   /* Deal with the title, if it is non-nil.  */
   if (!NILP (title))
     {
-      widget_value *wv_title = xmalloc_widget_value ();
-      widget_value *wv_sep = xmalloc_widget_value ();
+      widget_value *wv_title;
+      widget_value *wv_sep = make_widget_value ("--", NULL, false, Qnil);
 
       /* Maybe replace this separator with a bitmap or owner-draw item
         so that it looks better.  Having two separators looks odd.  */
-      wv_sep->name = "--";
       wv_sep->next = first_wv->contents;
-      wv_sep->help = Qnil;
 
       if (unicode_append_menu)
        title = ENCODE_UTF_8 (title);
       else if (STRING_MULTIBYTE (title))
        title = ENCODE_SYSTEM (title);
 
-      wv_title->name = SSDATA (title);
-      wv_title->enabled = TRUE;
+      wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
       wv_title->title = TRUE;
       wv_title->button_type = BUTTON_TYPE_NONE;
-      wv_title->help = Qnil;
       wv_title->next = wv_sep;
       first_wv->contents = wv_title;
     }
@@ -934,11 +903,7 @@
     pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
     pane_string = (NILP (pane_name)
                   ? "" : SSDATA (pane_name));
-    prev_wv = xmalloc_widget_value ();
-    prev_wv->value = pane_string;
-    prev_wv->enabled = 1;
-    prev_wv->name = "message";
-    prev_wv->help = Qnil;
+    prev_wv = make_widget_value ("message", pane_string, true, Qnil);
     first_wv = prev_wv;
 
     /* Loop over all panes and items, filling in the tree.  */
@@ -975,15 +940,13 @@
            return Qnil;
          }
 
-       wv = xmalloc_widget_value ();
+       wv = make_widget_value (button_names[nb_buttons],
+                               SSDATA (item_name),
+                               !NILP (enable), Qnil);
        prev_wv->next = wv;
-       wv->name = (char *) button_names[nb_buttons];
        if (!NILP (descrip))
          wv->key = SSDATA (descrip);
-       wv->value = SSDATA (item_name);
        wv->call_data = aref_addr (menu_items, i);
-       wv->enabled = !NILP (enable);
-       wv->help = Qnil;
        prev_wv = wv;
 
        if (! boundary_seen)
@@ -998,9 +961,7 @@
     if (! boundary_seen)
       left_count = nb_buttons - nb_buttons / 2;
 
-    wv = xmalloc_widget_value ();
-    wv->name = dialog_name;
-    wv->help = Qnil;
+    wv = make_widget_value (dialog_name, NULL, false, Qnil);
 
     /*  Frame title: 'Q' = Question, 'I' = Information.
         Can also have 'E' = Error if, one day, we want

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2014-05-29 17:16:00 +0000
+++ b/src/xmenu.c       2014-06-02 18:01:21 +0000
@@ -882,12 +882,8 @@
       /* Convert menu_items into widget_value trees
         to display the menu.  This cannot evaluate Lisp code.  */
 
-      wv = xmalloc_widget_value ();
-      wv->name = "menubar";
-      wv->value = 0;
-      wv->enabled = 1;
+      wv = make_widget_value ("menubar", NULL, true, Qnil);
       wv->button_type = BUTTON_TYPE_NONE;
-      wv->help = Qnil;
       first_wv = wv;
 
       for (i = 0; submenu_start[i] >= 0; i++)
@@ -952,12 +948,8 @@
       /* Make a widget-value tree containing
         just the top level menu bar strings.  */
 
-      wv = xmalloc_widget_value ();
-      wv->name = "menubar";
-      wv->value = 0;
-      wv->enabled = 1;
+      wv = make_widget_value ("menubar", NULL, true, Qnil);
       wv->button_type = BUTTON_TYPE_NONE;
-      wv->help = Qnil;
       first_wv = wv;
 
       items = FRAME_MENU_BAR_ITEMS (f);
@@ -969,12 +961,8 @@
          if (NILP (string))
            break;
 
-         wv = xmalloc_widget_value ();
-         wv->name = SSDATA (string);
-         wv->value = 0;
-         wv->enabled = 1;
+         wv = make_widget_value (SSDATA (string), NULL, true, Qnil);
          wv->button_type = BUTTON_TYPE_NONE;
-         wv->help = Qnil;
          /* This prevents lwlib from assuming this
             menu item is really supposed to be empty.  */
          /* The intptr_t cast avoids a warning.
@@ -1474,12 +1462,8 @@
 
   /* Create a tree of widget_value objects
      representing the panes and their items.  */
-  wv = xmalloc_widget_value ();
-  wv->name = "menu";
-  wv->value = 0;
-  wv->enabled = 1;
+  wv = make_widget_value ("menu", NULL, true, Qnil);
   wv->button_type = BUTTON_TYPE_NONE;
-  wv->help =Qnil;
   first_wv = wv;
   first_pane = 1;
 
@@ -1537,18 +1521,14 @@
             with its items as a submenu beneath it.  */
          if (!keymaps && strcmp (pane_string, ""))
            {
-             wv = xmalloc_widget_value ();
+             wv = make_widget_value (pane_string, NULL, true, Qnil);
              if (save_wv)
                save_wv->next = wv;
              else
                first_wv->contents = wv;
-             wv->name = (char *) pane_string;
              if (keymaps && !NILP (prefix))
                wv->name++;
-             wv->value = 0;
-             wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
-             wv->help = Qnil;
              save_wv = wv;
              prev_wv = 0;
            }
@@ -1586,20 +1566,18 @@
            }
 #endif /* not HAVE_MULTILINGUAL_MENU */
 
-         wv = xmalloc_widget_value ();
+         wv = make_widget_value (SSDATA (item_name), NULL, !NILP (enable),
+                                 STRINGP (help) ? help : Qnil);
          if (prev_wv)
            prev_wv->next = wv;
          else
            save_wv->contents = wv;
-         wv->name = SSDATA (item_name);
          if (!NILP (descrip))
            wv->key = SSDATA (descrip);
-         wv->value = 0;
          /* If this item has a null value,
             make the call_data null so that it won't display a box
             when the mouse is on it.  */
          wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
-         wv->enabled = !NILP (enable);
 
          if (NILP (type))
            wv->button_type = BUTTON_TYPE_NONE;
@@ -1612,11 +1590,6 @@
 
          wv->selected = !NILP (selected);
 
-          if (! STRINGP (help))
-           help = Qnil;
-
-         wv->help = help;
-
          prev_wv = wv;
 
          i += MENU_ITEMS_ITEM_LENGTH;
@@ -1626,27 +1599,20 @@
   /* Deal with the title, if it is non-nil.  */
   if (!NILP (title))
     {
-      widget_value *wv_title = xmalloc_widget_value ();
-      widget_value *wv_sep1 = xmalloc_widget_value ();
-      widget_value *wv_sep2 = xmalloc_widget_value ();
+      widget_value *wv_title;
+      widget_value *wv_sep1 = make_widget_value ("--", NULL, false, Qnil);
+      widget_value *wv_sep2 = make_widget_value ("--", NULL, false, Qnil);
 
-      wv_sep2->name = "--";
       wv_sep2->next = first_wv->contents;
-      wv_sep2->help = Qnil;
-
-      wv_sep1->name = "--";
       wv_sep1->next = wv_sep2;
-      wv_sep1->help = Qnil;
 
 #ifndef HAVE_MULTILINGUAL_MENU
       if (STRING_MULTIBYTE (title))
        title = ENCODE_MENU_STRING (title);
 #endif
 
-      wv_title->name = SSDATA (title);
-      wv_title->enabled = true;
+      wv_title = make_widget_value (SSDATA (title), NULL, true, Qnil);
       wv_title->button_type = BUTTON_TYPE_NONE;
-      wv_title->help = Qnil;
       wv_title->next = wv_sep1;
       first_wv->contents = wv_title;
     }
@@ -1867,11 +1833,7 @@
     pane_name = AREF (menu_items, MENU_ITEMS_PANE_NAME);
     pane_string = (NILP (pane_name)
                   ? "" : SSDATA (pane_name));
-    prev_wv = xmalloc_widget_value ();
-    prev_wv->value = (char *) pane_string;
-    prev_wv->enabled = 1;
-    prev_wv->name = "message";
-    prev_wv->help = Qnil;
+    prev_wv = make_widget_value ("message", (char *) pane_string, true, Qnil);
     first_wv = prev_wv;
 
     /* Loop over all panes and items, filling in the tree.  */
@@ -1907,15 +1869,13 @@
            return Qnil;
          }
 
-       wv = xmalloc_widget_value ();
+       wv = make_widget_value (button_names[nb_buttons],
+                               SSDATA (item_name),
+                               !NILP (enable), Qnil);
        prev_wv->next = wv;
-       wv->name = (char *) button_names[nb_buttons];
        if (!NILP (descrip))
          wv->key = SSDATA (descrip);
-       wv->value = SSDATA (item_name);
        wv->call_data = aref_addr (menu_items, i);
-       wv->enabled = !NILP (enable);
-       wv->help = Qnil;
        prev_wv = wv;
 
        if (! boundary_seen)
@@ -1930,9 +1890,7 @@
     if (! boundary_seen)
       left_count = nb_buttons - nb_buttons / 2;
 
-    wv = xmalloc_widget_value ();
-    wv->name = dialog_name;
-    wv->help = Qnil;
+    wv = make_widget_value (dialog_name, NULL, false, Qnil);
 
     /*  Frame title: 'Q' = Question, 'I' = Information.
         Can also have 'E' = Error if, one day, we want

=== modified file 'src/xterm.h'
--- a/src/xterm.h       2014-05-28 13:53:22 +0000
+++ b/src/xterm.h       2014-06-02 18:01:21 +0000
@@ -47,7 +47,6 @@
 
 /* Some definitions to reduce conditionals.  */
 typedef GtkWidget *xt_or_gtk_widget;
-#define XtParent(x) (gtk_widget_get_parent (x))
 #undef XSync
 #define XSync(d, b) do { gdk_window_process_all_updates (); \
                          XSync (d, b);  } while (false)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]