guile-user
[Top][All Lists]
Advanced

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

Re: marking SCM values in client data of port structure


From: Neil Jerram
Subject: Re: marking SCM values in client data of port structure
Date: Sat, 11 Mar 2006 09:42:39 +0000
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

"Marco Maggi" <address@hidden> writes:

>   So: is it mandatory to organise SCM values in the
> client data in a list and write the mark function to
> return the cons cells? That is the at the first invocation
> of the mark function we return the first cell and at
> subsequent invocations we return the cdr?

No.  If your client structure has n SCM slots, e.g.

struct client_data {
  int a;
  SCM b;
  char *c;
  SCM d;
  SCM e;
  float f[4];
  ...
}

your mark function just needs to call scm_gc_mark for each SCM:

client_mark (...)
{
  /* get client data pointer, then ... */
  scm_gc_mark (data->b);
  scm_gc_mark (data->d);
  scm_gc_mark (data->e);
  return SCM_BOOL_F;
}

If any of these SCMs is a compound object, scm_gc_mark will do the
recursion itself.

Did you try the documentation on this?  That should be easier than
trying to work it out from the code!  The relevant node is called
"Garbage Collecting Smobs".

      Neil





reply via email to

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