This is the mail archive of the
mailing list for the Guile project.
Re: Confusion on scm_make_smob_type
- To: Lars Arvestad <email@example.com>
- Subject: Re: Confusion on scm_make_smob_type
- From: Mikael Djurfeldt <firstname.lastname@example.org>
- Date: 31 Aug 1999 16:11:34 +0200
- Cc: email@example.com
- Cc: firstname.lastname@example.org
- References: <email@example.com>
Lars Arvestad <firstname.lastname@example.org> 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
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);