Skip to content
Snippets Groups Projects
Commit 6dd5c034 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Add function cdi_attribute_free().

parent 0967eac2
No related branches found
No related tags found
2 merge requests!34Version 2.2.0,!32M214003/develop
......@@ -225,6 +225,22 @@ cdiInqAttType(int cdiID, int varID, const char *name)
return type;
}
static void
cdi_attribute_free(cdi_att_t *attp)
{
if (attp->name)
{
Free(attp->name);
attp->name = NULL;
attp->namesz = 0;
}
if (attp->xvalue)
{
Free(attp->xvalue);
attp->xvalue = NULL;
}
}
int
cdiDeleteAtts(int cdiID, int varID)
{
......@@ -236,13 +252,7 @@ cdiDeleteAtts(int cdiID, int varID)
for (int attid = 0; attid < (int) attsp->nelems; attid++)
{
cdi_att_t *attp = &(attsp->value[attid]);
if (attp->name)
{
Free(attp->name);
attp->name = NULL;
attp->namesz = 0;
}
if (attp->xvalue) Free(attp->xvalue);
cdi_attribute_free(attp);
}
attsp->nelems = 0;
......@@ -263,15 +273,9 @@ cdiDelAtt(int cdiID, int varID, const char *name)
cdi_att_t *attp = &(attsp->value[attid]);
if (attp->name && str_is_equal(attp->name, name))
{
cdi_attribute_free(attp);
status = CDI_NOERR;
Free(attp->name);
attp->name = NULL;
attp->namesz = 0;
if (attp->xvalue)
{
Free(attp->xvalue);
attp->xvalue = NULL;
}
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment