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/line.c
struct libscols_line* scols_copy_line(const struct libscols_line* ln)
{
    struct libscols_line* ret;
    size_t i;

    if (!ln)
        return NULL;

    ret = scols_new_line();
    if (!ret)
        return NULL;
    if (scols_line_set_color(ret, ln->color))
        goto err;
    if (scols_line_alloc_cells(ret, ln->ncells))
        goto err;

    ret->userdata = ln->userdata;
    ret->ncells = ln->ncells;
    ret->seqnum = ln->seqnum;

    DBG(LINE, ul_debugobj(ln, "copy"));

    for (i = 0; i < ret->ncells; ++i)
    {
        if (scols_cell_copy_content(&ret->cells[i], &ln->cells[i]))
            goto err;
    }

    return ret;
err:
    scols_unref_line(ret);
    return NULL;
}
/**
 * scols_copy_line:
 * @ln: a pointer to a struct libscols_line instance
 *
 * Returns: A newly allocated copy of @ln, NULL in case of an error.
 */
@ln: a pointer to a struct libscols_line instance

A newly allocated copy of @ln, NULL in case of an error.
@ln : a pointer to a struct libscols_line instance A newly allocated copy of @ln NULL in case of an error .
struct libscols_line* scols_copy_line(const struct libscols_line* ln)
{
    struct libscols_line* ret;
    size_t i;
    if (!ln)
        return NULL;
    ret = scols_new_line();
    if (!ret)
        return NULL;
    if (scols_line_set_color(ret, ln->color))
        goto err;
    if (scols_line_alloc_cells(ret, ln->ncells))
        goto err;
    ret->userdata = ln->userdata;
    ret->ncells = ln->ncells;
    ret->seqnum = ln->seqnum;
    DBG(LINE, ul_debugobj(ln, "copy"));
    for (i = 0; i < ret->ncells; ++i)
    {
        if (scols_cell_copy_content(&ret->cells[i], &ln->cells[i]))
            goto err;
    }
    return ret;
err:
    scols_unref_line(ret);
    return NULL;
}
struct libscols_line * scols_copy_line ( const struct libscols_line * ln ) { struct libscols_line * ret ; size_t i ; if ( ! ln ) return NULL ; ret = scols_new_line ( ) ; if ( ! ret ) return NULL ; if ( scols_line_set_color ( ret , ln -> color ) ) goto err ; if ( scols_line_alloc_cells ( ret , ln -> ncells ) ) goto err ; ret -> userdata = ln -> userdata ; ret -> ncells = ln -> ncells ; ret -> seqnum = ln -> seqnum ; DBG ( LINE , ul_debugobj ( ln , " " ) ) ; for ( i = 0 ; i < ret -> ncells ; ++ i ) { if ( scols_cell_copy_content ( & ret -> cells [ i ] , & ln -> cells [ i ] ) ) goto err ; } return ret ; err : scols_unref_line ( ret ) ; return NULL ; }
scols_copy_line:
 @ln: a pointer to a struct libscols_line instance
scols_copy_line : @ln : a pointer to a struct libscols_line instance