Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct llist
- {
- char name[128];
- uint32_t value;
- struct llist *next;
- };
- typedef struct llist llist_t;
- void list_insert(llist_t **list, const char *name, uint32_t value)
- {
- llist_t *item = malloc(sizeof(struct llist));
- strcpy(item->name, name);
- item->value = value;
- item->next = *list;
- *list = item;
- }
- uint32_t list_find(llist_t **list, const char *name)
- {
- for(llist_t *it = *list; it != NULL; it = it->next)
- {
- if(strcmp(it->name, name) == 0) {
- return it->value;
- }
- }
- return -1;
- }
- void list_free(llist_t **list)
- {
- while((*list) != NULL)
- {
- llist_t *next = (*list)->next;
- free(*list);
- (*list) = next;
- }
- }
Add Comment
Please, Sign In to add comment