Skip to content
Snippets Groups Projects
Commit 49d7092b authored by Thomas Jahns's avatar Thomas Jahns :cartwheel:
Browse files

Consolidate vlistDestroy error checking.

parent 69434573
No related branches found
No related tags found
No related merge requests found
......@@ -1069,7 +1069,7 @@ void streamClose(int streamID)
if ( streamptr->filemode != 'w' && vlistInqTaxis(vlistID) != -1 )
taxisDestroy(vlistInqTaxis(vlistID));
cdiVlistDestroy_(vlistID);
cdiVlistDestroy_(vlistID, true);
}
stream_delete_entry(streamptr);
......
......@@ -251,6 +251,25 @@ vlist_delete(vlist_t *vlistptr)
vlist_delete_entry(vlistptr);
}
// destroy a vlist object
void cdiVlistDestroy_(int vlistID, bool assertInternal)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
static const char warningTextUserByInternal[]
= "Destroying a vlist object that is owned by the user (vlistID=%d).\n"
"This is most likely because of a missing vlistDestroy() in the application code.\n"
"If that's not the case, and you are absolutely certain about it, please report the bug.",
warningTextInternalByUser[]
= "Attempt to destroy an internal vlist object by the user (vlistID=%d).";
static const char *const wText[2]
= { warningTextUserByInternal, warningTextInternalByUser };
if (vlistptr->internal == assertInternal)
vlist_delete(vlistptr);
else
Warning(wText[!assertInternal], vlistID);
}
/*
@Function vlistDestroy
......@@ -264,25 +283,7 @@ vlist_delete(vlist_t *vlistptr)
*/
void vlistDestroy(int vlistID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
if ( vlistptr->internal )
Warning("Attempt to destroy an internal vlist object by the user (vlistID=%d).", vlistID);
else
vlist_delete(vlistptr);
}
// destroy an internal vlist object
void cdiVlistDestroy_(int vlistID)
{
vlist_t *vlistptr = vlist_to_pointer(vlistID);
if(!vlistptr->internal)
Warning("Destroying a vlist object that is owned by the user.\n"
"This is most likely because of a missing vlistDestroy() in the application code.\n"
"If that's not the case, and you are absolutely certain about it, please report the bug.");
vlist_delete(vlistptr);
cdiVlistDestroy_(vlistID, false);
}
static
......
......@@ -126,7 +126,7 @@ void vlistDestroyVarName(int vlistID, int varID);
void vlistDestroyVarLongname(int vlistID, int varID);
void vlistDestroyVarStdname(int vlistID, int varID);
void vlistDestroyVarUnits(int vlistID, int varID);
void cdiVlistDestroy_(int vlistID);
void cdiVlistDestroy_(int vlistID, bool assertInternal);
void vlistDefVarTsteptype(int vlistID, int varID, int tsteptype);
int vlistInqVarMissvalUsed(int vlistID, int varID);
int vlistHasTime(int vlistID);
......
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