openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libsmartcols/src/table.c
struct libscols_table* scols_copy_table(struct libscols_table* tb)
{
    struct libscols_table* ret;
    struct libscols_line* ln;
    struct libscols_column* cl;
    struct libscols_iter itr;

    if (!tb)
        return NULL;
    ret = scols_new_table();
    if (!ret)
        return NULL;

    DBG(TAB, ul_debugobj(tb, "copy"));

    if (tb->symbols)
        scols_table_set_symbols(ret, tb->symbols);

    /* columns */
    scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
    while (scols_table_next_column(tb, &itr, &cl) == 0)
    {
        cl = scols_copy_column(cl);
        if (!cl)
            goto err;
        if (scols_table_add_column(ret, cl))
            goto err;
        scols_unref_column(cl);
    }

    /* lines */
    scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
    while (scols_table_next_line(tb, &itr, &ln) == 0)
    {
        struct libscols_line* newln = scols_copy_line(ln);
        if (!newln)
            goto err;
        if (scols_table_add_line(ret, newln))
            goto err;
        if (ln->parent)
        {
            struct libscols_line* p =
                scols_table_get_line(ret, ln->parent->seqnum);
            if (p)
                scols_line_add_child(p, newln);
        }
        scols_unref_line(newln);
    }

    /* separators */
    if (scols_table_set_column_separator(ret, tb->colsep) ||
        scols_table_set_line_separator(ret, tb->linesep))
        goto err;

    return ret;
err:
    scols_unref_table(ret);
    return NULL;
}
/**
 * scols_copy_table:
 * @tb: table
 *
 * Creates a new independent table copy, except struct libscols_symbols that
 * are shared between the tables.
 *
 * Returns: a newly allocated copy of @tb
 */
@tb: table

Creates a new independent table copy, except struct libscols_symbols that
are shared between the tables.

a newly allocated copy of @tb
@tb : table Creates a new independent table copy except struct libscols_symbols that are shared between the tables . a newly allocated copy of @tb
struct libscols_table* scols_copy_table(struct libscols_table* tb)
{
    struct libscols_table* ret;
    struct libscols_line* ln;
    struct libscols_column* cl;
    struct libscols_iter itr;
    if (!tb)
        return NULL;
    ret = scols_new_table();
    if (!ret)
        return NULL;
    DBG(TAB, ul_debugobj(tb, "copy"));
    if (tb->symbols)
        scols_table_set_symbols(ret, tb->symbols);
    scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
    while (scols_table_next_column(tb, &itr, &cl) == 0)
    {
        cl = scols_copy_column(cl);
        if (!cl)
            goto err;
        if (scols_table_add_column(ret, cl))
            goto err;
        scols_unref_column(cl);
    }
    scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
    while (scols_table_next_line(tb, &itr, &ln) == 0)
    {
        struct libscols_line* newln = scols_copy_line(ln);
        if (!newln)
            goto err;
        if (scols_table_add_line(ret, newln))
            goto err;
        if (ln->parent)
        {
            struct libscols_line* p =
                scols_table_get_line(ret, ln->parent->seqnum);
            if (p)
                scols_line_add_child(p, newln);
        }
        scols_unref_line(newln);
    }
    if (scols_table_set_column_separator(ret, tb->colsep) ||
        scols_table_set_line_separator(ret, tb->linesep))
        goto err;
    return ret;
err:
    scols_unref_table(ret);
    return NULL;
}
struct libscols_table * scols_copy_table ( struct libscols_table * tb ) { struct libscols_table * ret ; struct libscols_line * ln ; struct libscols_column * cl ; struct libscols_iter itr ; if ( ! tb ) return NULL ; ret = scols_new_table ( ) ; if ( ! ret ) return NULL ; DBG ( TAB , ul_debugobj ( tb , " " ) ) ; if ( tb -> symbols ) scols_table_set_symbols ( ret , tb -> symbols ) ; scols_reset_iter ( & itr , SCOLS_ITER_FORWARD ) ; while ( scols_table_next_column ( tb , & itr , & cl ) == 0 ) { cl = scols_copy_column ( cl ) ; if ( ! cl ) goto err ; if ( scols_table_add_column ( ret , cl ) ) goto err ; scols_unref_column ( cl ) ; } scols_reset_iter ( & itr , SCOLS_ITER_FORWARD ) ; while ( scols_table_next_line ( tb , & itr , & ln ) == 0 ) { struct libscols_line * newln = scols_copy_line ( ln ) ; if ( ! newln ) goto err ; if ( scols_table_add_line ( ret , newln ) ) goto err ; if ( ln -> parent ) { struct libscols_line * p = scols_table_get_line ( ret , ln -> parent -> seqnum ) ; if ( p ) scols_line_add_child ( p , newln ) ; } scols_unref_line ( newln ) ; } if ( scols_table_set_column_separator ( ret , tb -> colsep ) || scols_table_set_line_separator ( ret , tb -> linesep ) ) goto err ; return ret ; err : scols_unref_table ( ret ) ; return NULL ; }
scols_copy_table:
 @tb: table
scols_copy_table : @tb : table
/* columns */ /* lines */ /* separators */