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

Add assertion to prevent double free problems.

parent 0c9384d7
No related branches found
No related tags found
No related merge requests found
......@@ -164,7 +164,7 @@ reshListCreate(int namespaceID)
/**************************************************************/
static void
reshRemove_(int nsp, int idx);
reshRemove_(int nsp, int idx, const char *caller);
void
reshListDestruct(int namespaceID)
......@@ -181,7 +181,7 @@ reshListDestruct(int namespaceID)
if (listElem->status & RESH_IN_USE_BIT)
{
listElem->res.v.ops->valDestroy(listElem->res.v.val);
reshRemove_(namespaceID, j);
reshRemove_(namespaceID, j, __func__);
}
}
Free(resHList[namespaceID].resources);
......@@ -301,10 +301,13 @@ int reshPut ( void *p, const resOps *ops )
/**************************************************************/
static void
reshRemove_(int nsp, int idx)
reshRemove_(int nsp, int idx, const char *caller)
{
int curFree = resHList[nsp].freeHead;
listElem_t *r = resHList[nsp].resources;
if (!(r[idx].status & RESH_IN_USE_BIT))
xabortC(caller,
"Attempting to remove an item that is already removed.");
r[idx].res.free.next = curFree;
r[idx].res.free.prev = -1;
if (curFree != -1)
......@@ -330,7 +333,7 @@ void reshDestroy(cdiResH resH)
&& resHList[nsp].resources[nspT.idx].res.v.ops);
if (resHList[nsp].resources[nspT.idx].status & RESH_IN_USE_BIT)
reshRemove_(nsp, nspT.idx);
reshRemove_(nsp, nspT.idx, __func__);
LIST_UNLOCK();
}
......@@ -353,7 +356,7 @@ void reshRemove ( cdiResH resH, const resOps * ops )
&& resHList[nsp].resources[nspT.idx].res.v.ops
&& resHList[nsp].resources[nspT.idx].res.v.ops == ops );
reshRemove_(nsp, nspT.idx);
reshRemove_(nsp, nspT.idx, __func__);
LIST_UNLOCK();
}
......@@ -373,7 +376,7 @@ void reshReplace(cdiResH resH, void *p, const resOps *ops)
if (q->status & RESH_IN_USE_BIT)
{
q->res.v.ops->valDestroy(q->res.v.val);
reshRemove_(nsp, nspT.idx);
reshRemove_(nsp, nspT.idx, __func__);
}
reshPut_(nsp, nspT.idx, p, ops);
LIST_UNLOCK();
......
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