#include #include #include struct list_entry { struct list_entry *next; int data; }; struct list_entry *ListHead = NULL; struct list_entry *ListTail = NULL; void insert( struct list_entry *new_entry ) { /* insert new_entry at end of linked list */ new_entry->next = NULL; _disable(); /* disable interrupts */ if( ListTail == NULL ) { ListHead = new_entry; } else { ListTail->next = new_entry; } ListTail = new_entry; _enable(); /* enable interrupts now */ } void main() { struct list_entry *p; int i; for( i = 1; i <= 10; i++ ) { p = (struct list_entry *) malloc( sizeof( struct list_entry ) ); if( p == NULL ) break; p->data = i; insert( p ); } }