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