sub_list.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028 #include <string.h>
00029 #include "../../mem/mem.h"
00030 #include "sub_list.h"
00031
00032 struct node* append_to_list(struct node *head, char *offset, char *name)
00033 {
00034 struct node *new_node;
00035
00036 new_node = pkg_malloc(sizeof(struct node));
00037 if (!new_node)
00038 return 0;
00039 new_node->offset = offset;
00040 new_node->name = name;
00041 new_node->next = head;
00042
00043 return new_node;
00044 }
00045
00046
00047
00048
00049 char* search_the_list(struct node *head, char *name)
00050 {
00051 struct node *n;
00052
00053 n = head;
00054 while (n) {
00055 if (strcasecmp(n->name,name)==0)
00056 return n->offset;
00057 n = n->next;
00058 }
00059 return 0;
00060 }
00061
00062
00063
00064
00065 void delete_list(struct node* head)
00066 {
00067 struct node *n;
00068 ;
00069 while (head) {
00070 n=head->next;
00071 pkg_free(head);
00072 head = n;
00073 }
00074 }
00075
00076