diff options
Diffstat (limited to 'pjlib/src/pjlib-samples/list.c')
-rw-r--r-- | pjlib/src/pjlib-samples/list.c | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/pjlib/src/pjlib-samples/list.c b/pjlib/src/pjlib-samples/list.c index 74e783f5..11518ebd 100644 --- a/pjlib/src/pjlib-samples/list.c +++ b/pjlib/src/pjlib-samples/list.c @@ -1,66 +1,66 @@ -/* $Header: /pjproject-0.3/pjlib/src/pjlib-samples/list.c 2 10/14/05 12:26a Bennylp $ */
-/*
- * $Log: /pjproject-0.3/pjlib/src/pjlib-samples/list.c $
- *
- * 2 10/14/05 12:26a Bennylp
- * Finished error code framework, some fixes in ioqueue, etc. Pretty
- * major.
- *
- * 1 10/10/05 5:12p Bennylp
- * Created.
- *
- */
-
-#include <pj/list.h>
-#include <pj/assert.h>
-#include <pj/log.h>
-
-/**
- * \page page_pjlib_samples_list_c Example: List Manipulation
- *
- * Below is sample program to demonstrate how to manipulate linked list.
- *
- * \includelineno pjlib-samples/list.c
- */
-
-struct my_node
-{
- // This must be the first member declared in the struct!
- PJ_DECL_LIST_MEMBER(struct my_node)
- int value;
-};
-
-
-int main()
-{
- struct my_node nodes[10];
- struct my_node list;
- struct my_node *it;
- int i;
-
- // Initialize the list as empty.
- pj_list_init(&list);
-
- // Insert nodes.
- for (i=0; i<10; ++i) {
- nodes[i].value = i;
- pj_list_insert_before(&list, &nodes[i]);
- }
-
- // Iterate list nodes.
- it = list.next;
- while (it != &list) {
- PJ_LOG(3,("list", "value = %d", it->value));
- it = it->next;
- }
-
- // Erase all nodes.
- for (i=0; i<10; ++i) {
- pj_list_erase(&nodes[i]);
- }
-
- // List must be empty by now.
- pj_assert( pj_list_empty(&list) );
-
- return 0;
-};
+/* $Header: /pjproject-0.3/pjlib/src/pjlib-samples/list.c 2 10/14/05 12:26a Bennylp $ */ +/* + * $Log: /pjproject-0.3/pjlib/src/pjlib-samples/list.c $ + * + * 2 10/14/05 12:26a Bennylp + * Finished error code framework, some fixes in ioqueue, etc. Pretty + * major. + * + * 1 10/10/05 5:12p Bennylp + * Created. + * + */ + +#include <pj/list.h> +#include <pj/assert.h> +#include <pj/log.h> + +/** + * \page page_pjlib_samples_list_c Example: List Manipulation + * + * Below is sample program to demonstrate how to manipulate linked list. + * + * \includelineno pjlib-samples/list.c + */ + +struct my_node +{ + // This must be the first member declared in the struct! + PJ_DECL_LIST_MEMBER(struct my_node) + int value; +}; + + +int main() +{ + struct my_node nodes[10]; + struct my_node list; + struct my_node *it; + int i; + + // Initialize the list as empty. + pj_list_init(&list); + + // Insert nodes. + for (i=0; i<10; ++i) { + nodes[i].value = i; + pj_list_insert_before(&list, &nodes[i]); + } + + // Iterate list nodes. + it = list.next; + while (it != &list) { + PJ_LOG(3,("list", "value = %d", it->value)); + it = it->next; + } + + // Erase all nodes. + for (i=0; i<10; ++i) { + pj_list_erase(&nodes[i]); + } + + // List must be empty by now. + pj_assert( pj_list_empty(&list) ); + + return 0; +}; |