[gclist] Segmentation faults + 2nd quick fix in mail

Boehm, Hans hans_boehm@hp.com
Tue, 1 May 2001 13:17:01 -0700


> From: elmex@x-paste.de [mailto:elmex@x-paste.de]
> struct L { char *a; char *b }; struct S { char *a; };
> ...
> struct L *ptr=GC_malloc(sizeof(struct L));
> struct S *sptr=NULL;
> struct L *lptr=NULL;
> ptr->a = GC_malloc(sizeof(char) * 4); ptr->a =
my_own_strdup_uses_GC_malloc("foo");
> ptr->b = GC_malloc(sizeof(char) * 4); ptr->b =
my_own_strdup_uses_GC_malloc("bar");
> 
Why the initial assignments 

ptr->a = GC_malloc(sizeof(char) * 4);
ptr->b = GC_malloc(sizeof(char) * 4);

?

They allocate memory that is immediately dropped.

I suspect you will have to post or mail me a complete example that fails
(the smaller the better) in order for us to make any progress here.

Hans