]> pd.if.org Git - zpackage/blob - libtomcrypt/src/pk/asn1/der/sequence/der_sequence_shrink.c
commit files needed for zpm-fetchurl
[zpackage] / libtomcrypt / src / pk / asn1 / der / sequence / der_sequence_shrink.c
1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
2  *
3  * LibTomCrypt is a library that provides various cryptographic
4  * algorithms in a highly modular and flexible manner.
5  *
6  * The library is free for all purposes without any express
7  * guarantee it works.
8  */
9 #include "tomcrypt.h"
10
11 /**
12   @file der_sequence_shrink.c
13   Free memory allocated for CONSTRUCTED, SET or SEQUENCE elements by der_decode_sequence_flexi(), Steffen Jaeckel
14 */
15
16 #ifdef LTC_DER
17
18 /**
19   Free memory allocated for CONSTRUCTED,
20   SET or SEQUENCE elements by der_decode_sequence_flexi()
21   @param in     The list to shrink
22 */
23 void der_sequence_shrink(ltc_asn1_list *in)
24 {
25    if (!in) return;
26
27    /* now walk the list and free stuff */
28    while (in != NULL) {
29       /* is there a child? */
30       if (in->child) {
31          der_sequence_shrink(in->child);
32       }
33
34       switch (in->type) {
35          case LTC_ASN1_CONSTRUCTED:
36          case LTC_ASN1_SET:
37          case LTC_ASN1_SEQUENCE : if (in->data != NULL) { XFREE(in->data); in->data = NULL; } break;
38          default: break;
39       }
40
41       /* move to next and free current */
42       in = in->next;
43    }
44 }
45
46 #endif
47
48 /* ref:         $Format:%D$ */
49 /* git commit:  $Format:%H$ */
50 /* commit time: $Format:%ai$ */