diff src/menubar.c @ 261:405dd6d1825b r20-5b29

Import from CVS: tag r20-5b29
author cvs
date Mon, 13 Aug 2007 10:23:51 +0200
parents 11cf20601dec
children b2472a1930f2
line wrap: on
line diff
--- a/src/menubar.c	Mon Aug 13 10:23:05 2007 +0200
+++ b/src/menubar.c	Mon Aug 13 10:23:51 2007 +0200
@@ -151,11 +151,22 @@
        (desc, path))
 {
   Lisp_Object path_entry, submenu_desc, submenu;
+  Lisp_Object *gui_item_array;
   struct gcpro gcpro1;
   struct gui_item gui_item;
 
   gui_item_init (&gui_item);
-  GCPRO1 (gui_item);
+
+  /*
+   * gui_item is a struct containing a bunch of Lisp_Object
+   * members.  We need to GC-protect all the member slots.
+   * Rather than build a long chain of individual gcpro structs
+   * that protect the slots individually, we protect all the
+   * member slots by pretending the struct is an array.  ANSI C
+   * requires tihs hack to work, ugly though it is.
+   */
+  gui_item_array = (Lisp_Object *) &gui_item;
+  GCPRO1 (gui_item_array[0]);
   gcpro1.nvars = GUI_ITEM_GCPRO_COUNT;
   
   EXTERNAL_LIST_LOOP (path_entry, path)