2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
5 Code to handle list of strings
11 #include "stringlist.h"
13 struct stringlist
*slist_append(struct stringlist
**list
, const char *s
)
15 struct stringlist
**listit
= list
;
16 struct stringlist
*node
= malloc(sizeof(struct stringlist
));
20 fprintf(stderr
, "Out of memory!\n");
24 while (*listit
!= NULL
) listit
= &(*listit
)->next
;
31 fprintf(stderr
, "Out of memory!\n");
38 struct stringlist
*slist_prepend(struct stringlist
**list
, const char *s
)
40 struct stringlist
**listit
= list
;
41 struct stringlist
*node
= malloc(sizeof(struct stringlist
));
45 fprintf(stderr
, "Out of memory!\n");
53 fprintf(stderr
, "Out of memory!\n");
61 int slist_remove(struct stringlist
**list
, struct stringlist
*node
)
63 struct stringlist
**listit
= list
;
65 while(*listit
!= NULL
&& *listit
!= node
) listit
= &(*listit
)->next
;
69 *listit
= (*listit
)->next
;
78 int slist_length(struct stringlist
*slist
)
82 for (i
=0; slist
; i
++, slist
=slist
->next
);