Commit 77c73b52 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Add missing destructor for vlist.

parent 03939f9b
......@@ -49,6 +49,9 @@ vlist_compare(vlist_t *a, vlist_t *b)
static void
vlistPrintKernel(vlist_t *vlistptr, FILE * fp );
static void
vlist_delete(vlist_t *vlistptr);
#ifdef USE_MPI
static int vlistGetSizeP ( void * vlistptr, MPI_Comm comm );
static void vlistPackP ( void * vlistptr, void * buff, int size,
......@@ -58,7 +61,7 @@ static int vlistTxCode ( void );
resOps vlist_ops = {
(valCompareFunc)vlist_compare,
free,
(valDestroyFunc)vlist_delete,
(valPrintFunc)vlistPrintKernel
#ifdef USE_MPI
, vlistGetSizeP,
......@@ -186,31 +189,18 @@ int vlistCreate(void)
return (vlistID);
}
/*
@Function vlistDestroy
@Title Destroy a variable list
@Prototype void vlistDestroy(int vlistID)
@Parameter
@Item vlistID Variable list ID, from a previous call to @fref{vlistCreate}
@EndFunction
*/
void vlistDestroy(int vlistID)
static void
vlist_delete(vlist_t *vlistptr)
{
vlist_t *vlistptr;
int nvars;
int varID;
vlistptr = vlist_to_pointer(vlistID);
vlist_check_ptr(__func__, vlistptr);
int vlistID = vlistptr->self;
vlistDelAtts(vlistID, CDI_GLOBAL);
nvars = vlistptr->nvars;
int nvars = vlistptr->nvars;
for ( varID = 0; varID < nvars; varID++ )
for (int varID = 0; varID < nvars; varID++ )
{
if ( vlistptr->vars[varID].levinfo ) free(vlistptr->vars[varID].levinfo);
if ( vlistptr->vars[varID].name ) free(vlistptr->vars[varID].name);
......@@ -222,12 +212,32 @@ void vlistDestroy(int vlistID)
if ( vlistptr->vars[varID].deco ) free(vlistptr->vars[varID].deco);
vlistDelAtts(vlistID, varID);
}
if ( vlistptr->vars ) free(vlistptr->vars);
vlist_delete_entry(vlistptr);
}
/*
@Function vlistDestroy
@Title Destroy a variable list
@Prototype void vlistDestroy(int vlistID)
@Parameter
@Item vlistID Variable list ID, from a previous call to @fref{vlistCreate}
@EndFunction
*/
void vlistDestroy(int vlistID)
{
vlist_t *vlistptr;
vlistptr = vlist_to_pointer(vlistID);
vlist_delete(vlistptr);
}
/*
@Function vlistCopy
@Title Copy a variable list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment