guile-user
[Top][All Lists]
Advanced

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

Re: smobs


From: Thamer Al-Harbash
Subject: Re: smobs
Date: Mon, 12 May 2003 03:19:52 -0400 (EDT)

On Sun, 11 May 2003, Dr. Peter Ivanyi wrote:

> How important to use the scm_must_malloc in the smob creation ?

All the code seems to do is call malloc and increment a size
counter in the garbage collector. By the looks of it it is meant
for the garbage collector to measure how close it gets to the
threshold which would cause it to run.

On the other hand there's a relationship between
scm_must_malloc() and your smob free routine. If you're not
honest you can get an abort(). Here's the relevant code from
libguile/gc.c:scm_must_malloc():

  if (nm  < size)
    /* The byte count of allocated objects has overflowed.  This is
       probably because you forgot to report the correct size of freed
       memory in some of your smob free methods. */
    abort ();


If you're going to use scm_must_malloc() then you have to report
the size in your smob free. Otherwise if you use malloc() it
looks like you should include the size of the data you got with
your own malloc() during your smob free.

Use gdb to see where the abort is being called. If its from that
piece of code, you know why.

-- 
Thamer Al-Harbash            http://www.whitefang.com/
        (if (> pressure too-much-pressure)
                'flame 'work)




reply via email to

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