On Wed, Aug 21, 2002 at 04:30:47AM +0900, William Djaja Tjokroaminata wrote:
> Hi,
> 
> To give it more context, suppose struct_B contains a VALUE (a pure VALUE,
> which is not a wrapper):
> 
>     typedef struct
>     {
>         VALUE data4;
>     } struct_B;
> 
> and the marking function for the top level wrapper object is as follows:
> 
>     ....
>     if (ptr->data1) rb_gc_mark (ptr->data1...);
>     if (ptr->data2) rb_gc_mark (ptr->data2->data4);
>     ....

In fact I wanted more detail about the top level object (the one that
is constructed with Data_Make_Struct), but I got it from you last reply
to Guy.

(copied here for reference)

 typedef struct {
	struct_C* data3;
 } struct_D;
 struct_D* c;

 VALUE res = Data_Make_Struct(rb_cObject, struct_D, 0, free, c);
 c->data3 = ALLOC(struct_C);
 
It get it now. I just couldn't see why you'd like to do
	ptr = ALLOC(struct_C);
instead of using Data_Make_Struct(). But well, I guess it's for
performance; since you're already making res, yet another VALUE if
pointless.

BTW, I do believe this thread wouldn't have been so loong if you had
explained before that the top level object manages (marks) things inside
struct_C instead of letting it do this itself. It turns out Guy's
last post reflects that he (amongst several others) thought there were
only two layers involved. As for me, I couldn't see why you were so
pressed to use ALLOC(struct_C) instead of Data_Make_Struct and letting it
manage its fields.
In fact, I now remember that's how this discussion started (performance when
wrapping C structs), but it was so long ago I think we all forgot it :-)

I consider we finally did Thread.current.kill ;->

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
  
"You, sir, are nothing but a pathetically lame salesdroid!
I fart in your general direction!"
	-- Randseed on #Linux