From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jan D." Newsgroups: gmane.emacs.devel Subject: Question about GC in C code. Date: Sat, 9 Nov 2002 21:36:00 +0100 (CET) Sender: emacs-devel-admin@gnu.org Message-ID: <200211092033.gA9KX7MU007609@stubby.bodenonline.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1036875125 12816 80.91.224.249 (9 Nov 2002 20:52:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 9 Nov 2002 20:52:05 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18AcaJ-0003KV-00 for ; Sat, 09 Nov 2002 21:52:03 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18AckQ-0006h2-00 for ; Sat, 09 Nov 2002 22:02:30 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18Acag-00030k-00; Sat, 09 Nov 2002 15:52:26 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18AcLz-0000tw-00 for emacs-devel@gnu.org; Sat, 09 Nov 2002 15:37:15 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18AcLw-0000tW-00 for emacs-devel@gnu.org; Sat, 09 Nov 2002 15:37:14 -0500 Original-Received: from stubby.bodenonline.com ([193.201.16.94]) by monty-python.gnu.org with esmtp (Exim 4.10) id 18AcLw-0000tJ-00 for emacs-devel@gnu.org; Sat, 09 Nov 2002 15:37:12 -0500 Original-Received: from pc35.bodenonline.com (IDENT:root@[193.201.16.44]) by stubby.bodenonline.com (8.12.1/8.12.1) with ESMTP id gA9KX7MU007609 for ; Sat, 9 Nov 2002 21:33:07 +0100 Original-To: emacs-devel@gnu.org Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9290 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9290 Hello. I have a question about how GC works in C. My problem is this: When a menu item is invoked in an Emacs built with a toolkit, a callback is invoked. That callback accesses an XVECTOR in the FRAME structure (Lisp_Object menu_bar_vector) to find out what event to produce. It is assumed that as long as the menus don't change, the XVECTOR stays the same. This is OK for toolkits used up till now. In Gtk, a menu can be detached, appearing as a small window of its own. But if the menus change in the frame where the detached menu originated from, the XVECTOR is not vaild for the detached menu anymore. So I made a small structure, like this: struct menu_gtk_data { FRAME_PTR f; Lisp_Object menu_bar_vector; int menu_bar_items_used; int ref_count; }; One such struct is malloc:ed and shared by all menu items. When the menus change, a new one is allocated. So any detached menu still has access to the old data. But I confess that I have no clue as how GC works in the C code. Will this approach work? Will menu_bar_vector be safe from GC? And when a struct menu_gtk_data is free:d, will menu_bar_vector then be a candidate for GC? I probably got this wrong, but how can I make this work? An alternative is to remove detachable menus of course. Jan D.