Beispiel #1
0
/* 
 *function : 生成指向hmap_e的list
 */
struct list* gethmapelist(struct hmap *mp)
{
    struct list *list = list_create_dt(fakefree);
    int i;
    for (i = 0; i < mp->hsize; i++)
    {
       if (mp->em[i] == NULL)
           continue;
       struct hmap_e *e = mp->em[i];
       while (e)
       {
           struct list_e *le = listnode_create(e);
           list_add(list, le);
           e = e->next;
       }
    }
    return list;
}
Beispiel #2
0
int
list_push_back(struct list* lst, void* newval)
{
    assert(lst != NULL);

    struct listnode* newnode = listnode_create(newval);
    if (newnode == NULL) {
        return ENOMEM;
    }

    if (lst->size == 0) {
        lst->head = newnode;
    } else {
        lst->tail->next = newnode;
    }
    lst->tail = newnode;

    ++lst->size;

    return 0;

}