unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan D." <jan.h.d@swipnet.se>
Subject: Question about GC in C code.
Date: Sat, 9 Nov 2002 21:36:00 +0100 (CET)	[thread overview]
Message-ID: <200211092033.gA9KX7MU007609@stubby.bodenonline.com> (raw)

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	other threads:[~2002-11-09 20:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-09 20:36 Jan D. [this message]
2002-11-11 10:20 ` Question about GC in C code Richard Stallman
2002-11-11 14:25   ` Jan D.
2002-11-12 12:49   ` Jan D.
2002-11-12 19:44     ` Stefan Monnier
2002-11-14  4:10     ` Richard Stallman
2002-11-14  6:18       ` Jan D.
2002-11-16  1:34         ` Richard Stallman
2002-11-16 12:37           ` Jan D.
2002-11-17  5:14             ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200211092033.gA9KX7MU007609@stubby.bodenonline.com \
    --to=jan.h.d@swipnet.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).