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/disk-utils/fdisk-list.c
int* init_fields(struct fdisk_context* cxt, const char* str, size_t* n)
{
    int* dflt_ids = NULL;
    struct fdisk_label* lb;

    if (!fields_string)
        fields_string = str;
    if (!cxt)
        goto done;

    lb = fdisk_get_label(cxt, NULL);

    if (!lb || fields_label != lb)
    { /* label changed: reset */
        free(fields_ids);
        fields_ids = NULL;
        fields_label = lb;
        fields_nids = 0;
    }

    if (!fields_label) /*  no label */
        goto done;
    if (fields_nids)
        goto done; /* already initialized */

    /* library default */
    if (fdisk_label_get_fields_ids(NULL, cxt, &dflt_ids, &fields_nids))
        goto done;

    fields_ids = xcalloc(FDISK_NFIELDS * 2, sizeof(int));

    /* copy defaults to the list with wanted fields */
    memcpy(fields_ids, dflt_ids, fields_nids * sizeof(int));
    free(dflt_ids);

    /* extend or replace fields_nids[] according to fields_string */
    if (fields_string &&
        string_add_to_idarray(fields_string, fields_ids, FDISK_NFIELDS * 2,
                              &fields_nids, fieldname_to_id) < 0)
        exit(EXIT_FAILURE);
done:
    fields_label = NULL;
    if (n)
        *n = fields_nids;
    return fields_ids;
}
/*
 * Initialize array with output columns (fields_ids[]) according to
 * comma delimited list of columns (@str). If the list string is not
 * defined then use library defaults. This function is "-o <list>"
 * backend.
 *
 * If the columns are already initialized then returns already existing columns.
 */
Initialize array with output columns (fields_ids[]) according to
comma delimited list of columns (@str). If the list string is not
defined then use library defaults. This function is "-o "
backend.

If the columns are already initialized then returns already existing columns.
Initialize array with output columns ( fields_ids [] ) according to comma delimited list of columns ( @str ) . If the list string is not defined then use library defaults . This function is " - o " backend . If the columns are already initialized then returns already existing columns .
int* init_fields(struct fdisk_context* cxt, const char* str, size_t* n)
{
    int* dflt_ids = NULL;
    struct fdisk_label* lb;
    if (!fields_string)
        fields_string = str;
    if (!cxt)
        goto done;
    lb = fdisk_get_label(cxt, NULL);
    if (!lb || fields_label != lb)
    { 
        free(fields_ids);
        fields_ids = NULL;
        fields_label = lb;
        fields_nids = 0;
    }
    if (!fields_label) 
        goto done;
    if (fields_nids)
        goto done; 
    if (fdisk_label_get_fields_ids(NULL, cxt, &dflt_ids, &fields_nids))
        goto done;
    fields_ids = xcalloc(FDISK_NFIELDS * 2, sizeof(int));
    memcpy(fields_ids, dflt_ids, fields_nids * sizeof(int));
    free(dflt_ids);
    if (fields_string &&
        string_add_to_idarray(fields_string, fields_ids, FDISK_NFIELDS * 2,
                              &fields_nids, fieldname_to_id) < 0)
        exit(EXIT_FAILURE);
done:
    fields_label = NULL;
    if (n)
        *n = fields_nids;
    return fields_ids;
}
int * init_fields ( struct fdisk_context * cxt , const char * str , size_t * n ) { int * dflt_ids = NULL ; struct fdisk_label * lb ; if ( ! fields_string ) fields_string = str ; if ( ! cxt ) goto done ; lb = fdisk_get_label ( cxt , NULL ) ; if ( ! lb || fields_label != lb ) { free ( fields_ids ) ; fields_ids = NULL ; fields_label = lb ; fields_nids = 0 ; } if ( ! fields_label ) goto done ; if ( fields_nids ) goto done ; if ( fdisk_label_get_fields_ids ( NULL , cxt , & dflt_ids , & fields_nids ) ) goto done ; fields_ids = xcalloc ( FDISK_NFIELDS * 2 , sizeof ( int ) ) ; memcpy ( fields_ids , dflt_ids , fields_nids * sizeof ( int ) ) ; free ( dflt_ids ) ; if ( fields_string && string_add_to_idarray ( fields_string , fields_ids , FDISK_NFIELDS * 2 , & fields_nids , fieldname_to_id ) < 0 ) exit ( EXIT_FAILURE ) ; done : fields_label = NULL ; if ( n ) * n = fields_nids ; return fields_ids ; }
Initialize array with output columns (fields_ids[]) according to
 comma delimited list of columns (@str).
Initialize array with output columns ( fields_ids [] ) according to comma delimited list of columns ( @str ) .
/* label changed: reset */ /*  no label */ /* already initialized */ /* library default */ /* copy defaults to the list with wanted fields */ /* extend or replace fields_nids[] according to fields_string */