链表常用的插入操作
typedef struct {
char *cmd;
void (*cmd_handle)();
struct _test_function_list *next;
}_test_function_list;
void append_object_to_list(void **head,char *cmd,void (*handle)())
{
_test_function_list *tmp = ((_test_function_list*)*head);
_test_function_list *newNode = (_test_function_list*)malloc(sizeof(_test_function_list));
if ( *head == NULL ) {
*head = newNode;
newNode->cmd = cmd;
newNode->cmd_handle = handle;
newNode->next = NULL;
return;
}
else {
while (tmp->next != NULL) {
tmp = tmp->next;
}
}
tmp->next = newNode;
newNode->cmd = cmd;
newNode->cmd_handle = handle;
newNode->next = NULL;
return;
}