Re: About linked lists

From: Mike Breuer (mbreuer@new.rr.com)
Date: 04/04/01


> Would that work? I learned link list in C++ and its uses the new
> operator so I have no idea about in C cept that here it doesn't
> use the new operator. If something is wrong with the code I just
> made up please help me fix it so I can use it. And what is that 1
> in CREATE for?

A quick glance at your code looks like it would properly create a linked
list of two elements.  The concept of the linked list is the same in C as it
is in C++ (or any low level language).  new and delete do not exist in C (as
you point out).  You will want to use malloc and free.  malloc is part of a
family of memory allocation functions that I suggest you read up on.

CREATE is a macro used in CircleMUD which wraps the calloc() function.  The
1 means you will allocate 1 * sizeof(type) bytes of memory.  You would pass
a number greater than 1 if you wanted to allocate a dynamic array.  Since
CircleMUD uses linked lists quite extensively, I would recommend
familiarizing yourself with them as much as possible before attempting any
significant code changes.

Mike

--
   +---------------------------------------------------------------+
   | 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