[Top][All Lists]

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

Re: GC garbles menu items

From: Juri Linkov
Subject: Re: GC garbles menu items
Date: Tue, 20 Dec 2005 23:54:07 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

>     I can reproduce this bug only on non-toolkit builds.
> Aha, now I see.  The non-toolkit definition of xmenu_show copies the
> addresses of string text directly into the non-toolkit menu data.
> When GC happens, it relocates the strings and garbles the text.

Is it possible to prevent relocation of the strings in GC for the time
while the menu is up?

> Could you rewrite that code to copy the strings when making the menus,
> and free the copies at the end?

I think it's safer not to change memory allocation code in non-toolkit
XMenu now just before the release.  I believe it is possible to solve
this problem by preventing string relocation the same way as it is done
for menu items where keyboard equivalents are displayed in the same menu
item.  Such menu items are constructed by the following code in xmenu_show
(and GC doesn't corrupt these menu items):

#ifdef C_ALLOCA
              Lisp_Object spacer;
              spacer = Fmake_string (make_number (gap), make_number (' '));
              item_name = concat2 (item_name, spacer);
              item_name = concat2 (item_name, descrip);
              item_data = SDATA (item_name);
              /* if alloca is fast, use that to make the space,
                 to reduce gc needs.  */
                = (unsigned char *) alloca (maxwidth
                                            + SBYTES (descrip) + 1);
              bcopy (SDATA (item_name), item_data,
                     SBYTES (item_name));
              for (j = SCHARS (item_name); j < maxwidth; j++)
                item_data[j] = ' ';
              bcopy (SDATA (descrip), item_data + j,
                     SBYTES (descrip));
              item_data[j + SBYTES (descrip)] = 0;

Juri Linkov

reply via email to

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