#ifdef TTBL
#include <stdio.h>
#include "tbl-incl.h"
void
TblFree PARAMS ((tbl, modName, typeName, v),
TBL *tbl _AND_
char *modName _AND_
char *typeName _AND_
AVal *v)
{
TBLModule *tblMod;
TBLTypeDef *tblTd;
tblTd = TblFindTypeDef (tbl, modName, typeName, &tblMod);
if (tblTd == NULL)
{
TblError ("TblFree: Could not find a type definition with the given module and name");
}
TblFreeType (tblTd->type, v);
}
void
TblFreeType PARAMS ((tblT, v),
TBLType *tblT _AND_
AVal *v)
{
AVal *elmtVPtr;
unsigned int currElmt;
TBLType *listElmtType;
TBLType *structElmtType;
TBLType *choiceElmtType;
AChoiceVal *cVal;
AStructVal *sVal;
AsnList *lVal;
void *tmp;
switch (tblT->typeId)
{
case TBL_TYPEREF:
TblFreeType (tblT->content->a.typeRef->typeDefPtr->type, v);
break;
case TBL_SEQUENCE:
case TBL_SET:
sVal = (AStructVal*)v;
currElmt = 0;
tmp = CURR_LIST_NODE (tblT->content->a.elmts);
FOR_EACH_LIST_ELMT (structElmtType, tblT->content->a.elmts)
{
if (!((structElmtType->optional) && (sVal[currElmt] == NULL)))
TblFreeType (structElmtType, sVal[currElmt]);
currElmt++;
}
SET_CURR_LIST_NODE (tblT->content->a.elmts, tmp);
Asn1Free (v);
break;
case TBL_SEQUENCEOF:
case TBL_SETOF:
listElmtType = FIRST_LIST_ELMT (tblT->content->a.elmts);
lVal = (AsnList*)v;
FOR_EACH_LIST_ELMT (elmtVPtr, lVal)
{
TblFreeType (listElmtType, elmtVPtr);
}
AsnListFree (lVal);
break;
case TBL_CHOICE:
cVal = (AChoiceVal*)v;
choiceElmtType = (TBLType*)GetAsnListElmt (tblT->content->a.elmts, cVal->choiceId);
TblFreeType (choiceElmtType, cVal->val);
Asn1Free (cVal);
break;
case TBL_BOOLEAN:
FreeAsnBool ((AsnBool*)v);
Asn1Free (v);
break;
case TBL_INTEGER:
case TBL_ENUMERATED:
FreeAsnInt ((AsnInt*)v);
Asn1Free (v);
break;
case TBL_BITSTRING:
FreeAsnBits ((AsnBits*)v);
Asn1Free (v);
break;
case TBL_OCTETSTRING:
FreeAsnOcts ((AsnOcts*)v);
Asn1Free (v);
break;
case TBL_NULL:
FreeAsnNull ((AsnNull*)v);
Asn1Free (v);
break;
case TBL_OID:
FreeAsnOid ((AsnOid*)v);
Asn1Free (v);
break;
case TBL_REAL:
FreeAsnReal ((AsnReal*)v);
Asn1Free (v);
break;
default:
break;
}
}
#endif