Re: GUILD related layout

From: Peter Ajamian (peter@pajamian.dhs.org)
Date: 04/01/01


Web Remedies Network wrote:
>
> > >    CREATE(new_train, struct trainer_data, 1);
> > >    new_train->next = mob_proto[i].mob_specials.trainer;
> > >    mob_proto[i].mob_specials.trainer->prev = new_train;
> >
>
> might anyone know a work around or
> sollution
> to this problem?

If  you want a fifo see the code I already posted in my last reply.  If
you want a simple linked list then try this (pseudocode, trainer is just
the end of the variable)...

new_train->next = trainer;
trainer = new_train;

That's a safe way to add a new element to the head of a list because you
are never actually dereferencing the pointer to the head (if you don't
care about the prev pointer that is).  If you have to do something that
might dereference a NULL pointer, then all you have to do is check for
the NULL before you dereference it.

Regards, Peter

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST