Ejemplo n.º 1
0
const void *
atf_list_index_c(const atf_list_t *list, const size_t idx)
{
    atf_list_citer_t iter;

    PRE(idx < atf_list_size(list));

    iter = atf_list_begin_c(list);
    {
        size_t pos = 0;
        while (pos < idx &&
               !atf_equal_list_citer_list_citer((iter),
                                                atf_list_end_c(list))) {
            iter = atf_list_citer_next(iter);
            pos++;
        }
    }
    return atf_list_citer_data(iter);
}
Ejemplo n.º 2
0
static
atf_error_t
list_to_array(const atf_list_t *l, char ***ap)
{
    atf_error_t err;
    char **a;

    a = (char **)malloc((atf_list_size(l) + 1) * sizeof(char *));
    if (a == NULL)
        err = atf_no_memory_error();
    else {
        char **aiter;
        atf_list_citer_t liter;

        aiter = a;
        atf_list_for_each_c(liter, l) {
            *aiter = strdup((const char *)atf_list_citer_data(liter));
            aiter++;
        }
        *aiter = NULL;

        err = atf_no_error();
    }