This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Confusion on scm_make_smob_type
- To: Lars Arvestad <arve@nada.kth.se>
- Subject: Re: Confusion on scm_make_smob_type
- From: Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se>
- Date: 31 Aug 1999 16:11:34 +0200
- Cc: guile@sourceware.cygnus.com
- Cc: djurfeldt@nada.kth.se
- References: <yueemgkoxy6.fsf@turing.nada.kth.se>
Lars Arvestad <arve@nada.kth.se> writes:
> I would really appreciate two very simple examples:
> 1. An smob for a C struct. No pointers to malloced memory.
> 2. An smob for a pointer to a malloced C struct.
> I know how to do this (or think I do!), but I don't understand what I
> can get for free from libguile. What is the most simple way to do
> this?
I don't understand the difference between these two.
Aren't C structs always malloc:ed when you use them as smobs?
What would the alternative be?
One thing you get for free when you give a SIZE argument to
scm_make_smob_type is the default free function. (free has to tell
Guile (by its return value) how much memory was freed).
If you don't have any SCM objects in your malloc:ed memory block, you
also get a free constructor. In this case, the following two lines is
all you have to do:
SCM type = scm_make_smob_type ("my-type", SIZE);
SCM my_smob = scm_make_smob (type);