Encoding a Series of Messages Using the C Encode Functions

Encoding a series of messages in MDER is very similar to encoding a series of messages in any other set of encoding rules. Performance can be improved by calling rtxMemReset to avoid allocating new memory for dynamic message structures, as in the code below:

   /* initialize context, et c. */   
            
   for ( ; ; ) {
      /* initialize / populate message structure to be encoded */
      
      /* call MDEREnc_<messageType> (...); */
      
      /* call rtxMemReset when finished encoding: */
      rtxMemReset (pctxt);
   }

More details may be found in the sample programs included in the ASN1C software development kit.