Improved list example
This commit is contained in:
parent
d9e1e9d037
commit
9fd33a1211
|
@ -1,4 +1,4 @@
|
||||||
#include "list.h"
|
#include "lib/list.h"
|
||||||
|
|
||||||
struct example_list_struct {
|
struct example_list_struct {
|
||||||
struct *next;
|
struct *next;
|
||||||
|
@ -7,21 +7,24 @@ struct example_list_struct {
|
||||||
|
|
||||||
LIST(example_list);
|
LIST(example_list);
|
||||||
|
|
||||||
|
static struct example_list_struct element1, element2;
|
||||||
|
|
||||||
void
|
void
|
||||||
example_function(void)
|
example_function(void)
|
||||||
{
|
{
|
||||||
struct example_list_struct *s;
|
struct example_list_struct *s;
|
||||||
struct example_list_struct element1, element2;
|
|
||||||
|
|
||||||
list_init(example_list);
|
list_init(example_list);
|
||||||
|
|
||||||
|
element1.number = 1;
|
||||||
list_add(example_list, &element1);
|
list_add(example_list, &element1);
|
||||||
|
|
||||||
|
element2.number = 2;
|
||||||
list_add(example_list, &element2);
|
list_add(example_list, &element2);
|
||||||
|
|
||||||
for(s = list_head(example_list);
|
for(s = list_head(example_list);
|
||||||
s != NULL;
|
s != NULL;
|
||||||
s = s->next) {
|
s = s->next) {
|
||||||
printf("List element number %d\n", s->number);
|
printf("List element number %d\n", s->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue