1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 3 #include "tomcrypt_private.h" 4 5 /** 6 @file der_sequence_shrink.c 7 Free memory allocated for CONSTRUCTED, SET or SEQUENCE elements by der_decode_sequence_flexi(), Steffen Jaeckel 8 */ 9 10 #ifdef LTC_DER 11 12 /** 13 Free memory allocated for CONSTRUCTED, 14 SET or SEQUENCE elements by der_decode_sequence_flexi() 15 @param in The list to shrink 16 */ der_sequence_shrink(ltc_asn1_list * in)17void der_sequence_shrink(ltc_asn1_list *in) 18 { 19 if (!in) return; 20 21 /* now walk the list and free stuff */ 22 while (in != NULL) { 23 /* is there a child? */ 24 if (in->child) { 25 der_sequence_shrink(in->child); 26 } 27 28 switch (in->type) { 29 case LTC_ASN1_CUSTOM_TYPE: 30 case LTC_ASN1_SET: 31 case LTC_ASN1_SEQUENCE : if (in->data != NULL) { XFREE(in->data); in->data = NULL; } break; 32 default: break; 33 } 34 35 /* move to next and free current */ 36 in = in->next; 37 } 38 } 39 40 #endif 41