Как мой указатель LINKED_LIST может оставаться NULL?

основная функция:

int main()
{
    if((ban_file = open_file("banned_ips.txt")) == NULL)
        goto exit;

    ban_lst = NULL;
    cpy_to_list(ban_file, ban_lst);
    close_file(ban_file);
    dealloc_list(ban_lst);
exit:
    return 0;
}

функция cpy_to_list:

void cpy_to_list(FILE *file, LINKED_LIST *lst)
{
    char *line = malloc(1024);

    while((line = fgets(line, 1024, file)) != NULL)
    {
        add_node(line, lst);
    }

    free(line);
}

add_node, dealloc_list и create_list:

LINKED_LIST *create_list(void)
{
    LINKED_LIST *tmp;

    if((tmp = malloc(sizeof(LINKED_LIST))) == NULL)
        perror("Error during memory allocation");

    return tmp;
}

void add_node(const char *str, LINKED_LIST *lst)
{
    struct list_node *tmp_node;

    tmp_node = create_list();
    tmp_node->str = str;

    if(lst != NULL)
    {
        tmp_node->next = lst;
        lst = tmp_node;
    }
    else
    {
        lst = tmp_node;
        lst->next = NULL;
    }
}

void dealloc_list(LINKED_LIST *ptr)
{
    free(ptr);
}

Почему ban_lst является указателем NULL?

0
задан Benjamin 7 February 2012 в 20:02
поделиться