guile-devel
[Top][All Lists]
Advanced

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

Re: GC + Java finalization


From: Jonas Hahnfeld
Subject: Re: GC + Java finalization
Date: Fri, 19 Nov 2021 14:35:44 +0100
User-agent: Evolution 3.42.1

Am Freitag, dem 19.11.2021 um 13:15 +0000 schrieb Maxime Devos:
> Jonas Hahnfeld schreef op do 15-07-2021 om 20:44 [+0200]:
> > +  SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs");
> > +
> >    int i;
> >    mark_call_count = 0;
> >    for (i = 0; i < SMOBS_COUNT; i++)
> > -    make_x ();
> > +    smobs[i] = make_x ();
> >    scm_gc ();
> 
> smobs doesn't need to be protected for the whole function call,
> until after the scm_gc() should be sufficient I think. 

That's what the patch does, no? For reference, the whole function
(after this patch) looks like:

SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs");

int i;
mark_call_count = 0;
for (i = 0; i < SMOBS_COUNT; i++)
  smobs[i] = make_x (); 
scm_gc (); 
if (mark_call_count < SMOBS_COUNT)
  {   
    fprintf (stderr, "FAIL: SMOB mark function called for each SMOB\n");
    exit (EXIT_FAILURE);
  }   
scm_remember_upto_here_1 (smobs);

While we could move the remember_upto_here immediately after the call
to scm_gc(), the current version ensures that the memory is still
available when the error is checked.

Jonas

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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