emacs-devel
[Top][All Lists]
Advanced

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

Re: Emacs and Gnome Canvas


From: Eli Zaretskii
Subject: Re: Emacs and Gnome Canvas
Date: Sat, 17 Jul 2010 10:57:55 +0300

> From: Óscar Fuentes <address@hidden>
> Date: Sat, 17 Jul 2010 02:08:43 +0200
> 
> Second, whatever mechanism Emacs uses for memory management, it is
> usable from C++ as well (for dealing with Emacs objects, of course.)

How can you be sure?

Emacs overrides the default `malloc' and `sbrk' functions, at least on
some platforms, and replaces them with its own implementations.  Those
implementations relocate large objects on the heap behind the scenes,
whenever Emacs sees fit.  I'm not sure this is "usable from C++" out
of the box.  C++ objects that hold pointers to arrays might suddenly
find those pointers invalidated by the above-mentioned relocation.

We had quite a few bugs caused by that in Emacs, even though the issue
is well known and there are special protocols in Emacs sources to
follow in order to avoid that.  See, for example these messages
regarding one such bug:

  http://lists.gnu.org/archive/html/emacs-devel/2010-02/msg00666.html
  http://lists.gnu.org/archive/html/emacs-devel/2010-02/msg00702.html
  http://lists.gnu.org/archive/html/emacs-devel/2010-03/msg00088.html

If you want to see the fix, it's revno 99601 on the trunk.

> Is it better to not try it, then?

No.  But you need to be careful when you are choosing your tools of
trade -- they need to allow you to concentrate on the important
issues, instead of wasting energy on obstacles that have nothing to do
with the problems you intend to solve.




reply via email to

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