lkml.org 
[lkml]   [2005]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Ordered Sorted List
Date
Nanakos Chrysostomos wrote:
> Hi ,all.Can someone please explain this source code with an example???
.....
> void slistInsert(slist *sp,int t)
> {
> ListNode *n=(ListNode *)malloc(sizeof(ListNode));
> if(n == NULL)
> {
> printf("Out of memory\n");
> exit(1);
> }
> n->data = t;
> while(*sp!=NULL && (*sp)->data < t)
> {
> sp = &((*sp)->next); // Why we do this here,i miss this point

This is done to move to the next item in the list.
The expression is complicated because 'sp' is a pointer to a pointer to
a structure.

> }
> n->next = *sp;
> *sp = n;
>
> }
>
.....

--
Matthijs Melchior.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-11-26 21:09    [W:0.030 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site