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) ...@@ -49,6 +49,9 @@ vlist_compare(vlist_t *a, vlist_t *b)
static void static void
vlistPrintKernel(vlist_t *vlistptr, FILE * fp ); vlistPrintKernel(vlist_t *vlistptr, FILE * fp );
static void
vlist_delete(vlist_t *vlistptr);
#ifdef USE_MPI #ifdef USE_MPI
static int vlistGetSizeP ( void * vlistptr, MPI_Comm comm ); static int vlistGetSizeP ( void * vlistptr, MPI_Comm comm );
static void vlistPackP ( void * vlistptr, void * buff, int size, static void vlistPackP ( void * vlistptr, void * buff, int size,
...@@ -58,7 +61,7 @@ static int vlistTxCode ( void ); ...@@ -58,7 +61,7 @@ static int vlistTxCode ( void );
resOps vlist_ops = { resOps vlist_ops = {
(valCompareFunc)vlist_compare, (valCompareFunc)vlist_compare,
free, (valDestroyFunc)vlist_delete,
(valPrintFunc)vlistPrintKernel (valPrintFunc)vlistPrintKernel
#ifdef USE_MPI #ifdef USE_MPI
, vlistGetSizeP, , vlistGetSizeP,
...@@ -186,31 +189,18 @@ int vlistCreate(void) ...@@ -186,31 +189,18 @@ int vlistCreate(void)
return (vlistID); return (vlistID);
} }
/* static void
@Function vlistDestroy vlist_delete(vlist_t *vlistptr)
@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;
int nvars;
int varID;
vlistptr = vlist_to_pointer(vlistID);
vlist_check_ptr(__func__, vlistptr); vlist_check_ptr(__func__, vlistptr);
int vlistID = vlistptr->self;
vlistDelAtts(vlistID, CDI_GLOBAL); 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].levinfo ) free(vlistptr->vars[varID].levinfo);
if ( vlistptr->vars[varID].name ) free(vlistptr->vars[varID].name); if ( vlistptr->vars[varID].name ) free(vlistptr->vars[varID].name);
...@@ -222,12 +212,32 @@ void vlistDestroy(int vlistID) ...@@ -222,12 +212,32 @@ void vlistDestroy(int vlistID)
if ( vlistptr->vars[varID].deco ) free(vlistptr->vars[varID].deco); if ( vlistptr->vars[varID].deco ) free(vlistptr->vars[varID].deco);
vlistDelAtts(vlistID, varID); vlistDelAtts(vlistID, varID);
} }
if ( vlistptr->vars ) free(vlistptr->vars); if ( vlistptr->vars ) free(vlistptr->vars);
vlist_delete_entry(vlistptr); 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 @Function vlistCopy
@Title Copy a variable list @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