]>
git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/c-lib/src/tbl-free.c
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
22 * tbl_free.c - frees data structs returned by type table driven decoder.
27 * Copyright (C) 1993 Michael Sample
28 * and the University of British Columbia
29 * This library is free software; you can redistribute it and/or
30 * modify it provided that this copyright/license information is retained
33 * If you modify this file, you must clearly indicate your changes.
35 * This source code is distributed in the hope that it will be
36 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
37 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
46 TblFree
PARAMS ((tbl
, modName
, typeName
, v
),
55 tblTd
= TblFindTypeDef (tbl
, modName
, typeName
, &tblMod
);
58 TblError ("TblFree: Could not find a type definition with the given module and name");
61 TblFreeType (tblTd
->type
, v
);
66 TblFreeType
PARAMS ((tblT
, v
),
71 unsigned int currElmt
;
72 TBLType
*listElmtType
;
73 TBLType
*structElmtType
;
74 TBLType
*choiceElmtType
;
84 TblFreeType (tblT
->content
->a
.typeRef
->typeDefPtr
->type
, v
);
89 sVal
= (AStructVal
*)v
;
91 tmp
= CURR_LIST_NODE (tblT
->content
->a
.elmts
);
92 FOR_EACH_LIST_ELMT (structElmtType
, tblT
->content
->a
.elmts
)
94 if (!((structElmtType
->optional
) && (sVal
[currElmt
] == NULL
)))
95 TblFreeType (structElmtType
, sVal
[currElmt
]);
98 SET_CURR_LIST_NODE (tblT
->content
->a
.elmts
, tmp
);
105 listElmtType
= FIRST_LIST_ELMT (tblT
->content
->a
.elmts
);
107 FOR_EACH_LIST_ELMT (elmtVPtr
, lVal
)
109 TblFreeType (listElmtType
, elmtVPtr
);
115 cVal
= (AChoiceVal
*)v
;
116 choiceElmtType
= (TBLType
*)GetAsnListElmt (tblT
->content
->a
.elmts
, cVal
->choiceId
);
117 TblFreeType (choiceElmtType
, cVal
->val
);
122 FreeAsnBool ((AsnBool
*)v
);
128 FreeAsnInt ((AsnInt
*)v
);
133 FreeAsnBits ((AsnBits
*)v
);
137 case TBL_OCTETSTRING
:
138 FreeAsnOcts ((AsnOcts
*)v
);
143 FreeAsnNull ((AsnNull
*)v
);
148 FreeAsnOid ((AsnOid
*)v
);
153 FreeAsnReal ((AsnReal
*)v
);