emacs-devel
[Top][All Lists]
Advanced

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

Question about GC in C code.


From: Jan D.
Subject: Question about GC in C code.
Date: Sat, 9 Nov 2002 21:36:00 +0100 (CET)

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.





reply via email to

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