src/libmetha/attr.c
M_CODE
lm_attrlist_prepare(attr_list_t *al, const char **attributes,
                    unsigned num_attributes)
{
    int x;

    /* free all existing values */
    if (al->num_attributes)
        for (x=0; x<al->num_attributes; x++)
            if (al->list[x].value)
                free(al->list[x].value);
    
    if (num_attributes) {
        if (!(al->list = realloc(al->list, num_attributes*sizeof(attr_t))))
            return M_OUT_OF_MEM;
    } else {
        free(al->list);
        al->list = 0;
    }

    for (x=0; x<num_attributes; x++) {
        al->list[x].name = attributes[x];
        al->list[x].value = 0;
        al->list[x].size = 0;
    }

    al->num_attributes = num_attributes;
    al->changed = 0;

    return M_OK;
}
/** 
 * Prepare the given attr_list_t.
 *
 * 'attributes' will point to an array of attribute names
 * that should be in this attribute list. For each element
 * in the array, an attr_t is created in the list.
 *
 * The created attr_t fields will point to the given names
 * in 'attribute' directly and not create copies of them.
 *
 * If the attr list contains any elements already, their 
 * values are freed.
 *
 * M_OK should be returned unless out of memory.
 **/
Prepare the given attr_list_t.
'attributes' will point to an array of attribute names
that should be in this attribute list. For each element
in the array, an attr_t is created in the list.

The created attr_t fields will point to the given names
in 'attribute' directly and not create copies of them.

If the attr list contains any elements already, their
values are freed.

M_OK should be returned unless out of memory.
Prepare the given attr_list_t . ' attributes ' will point to an array of attribute names that should be in this attribute list . For each element in the array an attr_t is created in the list . The created attr_t fields will point to the given names in ' attribute ' directly and not create copies of them . If the attr list contains any elements already their values are freed . M_OK should be returned unless out of memory .
M_CODE
lm_attrlist_prepare(attr_list_t *al, const char **attributes,
                    unsigned num_attributes)
{
    int x;
    if (al->num_attributes)
        for (x=0; x<al->num_attributes; x++)
            if (al->list[x].value)
                free(al->list[x].value);
    if (num_attributes) {
        if (!(al->list = realloc(al->list, num_attributes*sizeof(attr_t))))
            return M_OUT_OF_MEM;
    } else {
        free(al->list);
        al->list = 0;
    }
    for (x=0; x<num_attributes; x++) {
        al->list[x].name = attributes[x];
        al->list[x].value = 0;
        al->list[x].size = 0;
    }
    al->num_attributes = num_attributes;
    al->changed = 0;
    return M_OK;
}
M_CODE lm_attrlist_prepare ( attr_list_t * al , const char * * attributes , unsigned num_attributes ) { int x ; if ( al -> num_attributes ) for ( x = 0 ; x < al -> num_attributes ; x ++ ) if ( al -> list [ x ] . value ) free ( al -> list [ x ] . value ) ; if ( num_attributes ) { if ( ! ( al -> list = realloc ( al -> list , num_attributes * sizeof ( attr_t ) ) ) ) return M_OUT_OF_MEM ; } else { free ( al -> list ) ; al -> list = 0 ; } for ( x = 0 ; x < num_attributes ; x ++ ) { al -> list [ x ] . name = attributes [ x ] ; al -> list [ x ] . value = 0 ; al -> list [ x ] . size = 0 ; } al -> num_attributes = num_attributes ; al -> changed = 0 ; return M_OK ; }
Prepare the given attr_list_t.
Prepare the given attr_list_t .
/* free all existing values */