Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void alias_list_delete(struct alias_list *list)
- {
- struct alias *current = list->first;
- while (current != NULL)
- {
- struct alias *previous = current;
- current = current->next;
- alias_delete(previous);
- }
- free(list);
- }
- // Append the given (key, value) pair to the given list
- //
- // Python: list.append((key, value))
- void alias_list_append(struct alias_list *list, char *key, char *value)
- {
- if (list->first==NULL){
- struct *alias = alias_create(key, value);
- list->first = alias;
- }
- else{
- struct alias *current = list->first;
- while (current->next != NULL){
- current = current->next;
- }
- struct *alias = alias_create(key, value);
- current->next = alias;
- }
- }
- // Return the value of the element with the given key. If the given key was not
- // found, the value NULL is returned.
- char *alias_list_lookup(struct alias_list *list, char *key)
- {
- if(list->first!=NULL){
- struct *current=list->first;
- if(strcmp(current->key,key)==0){
- return current->value;
- }
- while(current->next!=NULL){
- current = current->next;
- if(strcmp(current->key,key)==0){
- return current->value;
- }
- }
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment