unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A question about struct coding_system
@ 2011-11-21 16:13 Dmitry Antipov
  2011-11-21 16:55 ` Andreas Schwab
  2011-11-21 17:47 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Antipov @ 2011-11-21 16:13 UTC (permalink / raw)
  To: emacs-devel

At a first glance, struct coding_system should be a vector-like
object with src_object and dst_object at the beginning. But it
isn't, and it looks like that src_object and dst_object are never
marked directly. Thus, it should be guaranteed that, for any
coding_system, objects referenced by src_object and dst_object
are always reachable from another live objects. But I can't
find any code that takes care about this, so I don't understand
why and how it works at all :-(.

Dmitry



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about struct coding_system
  2011-11-21 16:13 A question about struct coding_system Dmitry Antipov
@ 2011-11-21 16:55 ` Andreas Schwab
  2011-11-21 20:22   ` Stefan Monnier
  2011-11-21 17:47 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2011-11-21 16:55 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: emacs-devel

Dmitry Antipov <antipov@mvista.com> writes:

> At a first glance, struct coding_system should be a vector-like
> object with src_object and dst_object at the beginning. But it
> isn't, and it looks like that src_object and dst_object are never
> marked directly. Thus, it should be guaranteed that, for any
> coding_system, objects referenced by src_object and dst_object
> are always reachable from another live objects. But I can't
> find any code that takes care about this, so I don't understand
> why and how it works at all :-(.

It's generally the duty of the caller to protect the object.  If it is a
buffer it should be the current buffer.  If it is passed in from Lisp it
is already protected.  Other cases should be explicitly protected.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about struct coding_system
  2011-11-21 16:13 A question about struct coding_system Dmitry Antipov
  2011-11-21 16:55 ` Andreas Schwab
@ 2011-11-21 17:47 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2011-11-21 17:47 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: emacs-devel

> At a first glance, struct coding_system should be a vector-like
> object with src_object and dst_object at the beginning. But it
> isn't, and it looks like that src_object and dst_object are never
> marked directly. Thus, it should be guaranteed that, for any
> coding_system, objects referenced by src_object and dst_object
> are always reachable from another live objects. But I can't
> find any code that takes care about this, so I don't understand
> why and how it works at all :-(.

It may very well work just by accident (the "global" coding_system
objects have src/dst_object fields that contain globally live objects
such as nil, while the others point to objects that are also reachable
via some local variable).


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about struct coding_system
  2011-11-21 16:55 ` Andreas Schwab
@ 2011-11-21 20:22   ` Stefan Monnier
  2011-11-21 20:32     ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2011-11-21 20:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Dmitry Antipov, emacs-devel

> It's generally the duty of the caller to protect the object.

No, Emacs's C code generally puts the burden on the callee rather than
the caller (with a few exceptions like Ffuncall).


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A question about struct coding_system
  2011-11-21 20:22   ` Stefan Monnier
@ 2011-11-21 20:32     ` Andreas Schwab
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2011-11-21 20:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Dmitry Antipov, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> It's generally the duty of the caller to protect the object.
>
> No, Emacs's C code generally puts the burden on the callee rather than
> the caller (with a few exceptions like Ffuncall).

I'm talking only about the caller of (en|de)code_coding_*.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-21 20:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21 16:13 A question about struct coding_system Dmitry Antipov
2011-11-21 16:55 ` Andreas Schwab
2011-11-21 20:22   ` Stefan Monnier
2011-11-21 20:32     ` Andreas Schwab
2011-11-21 17:47 ` Stefan Monnier

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).