Using Initialization Functions

Initialization functions are generated by the ASN1C compiler when the -genInit option is added to the ASN1C command-line. These functions can be used as an alternative to memset’ing a variable to zero to prepare it to receive decoded data. The advantage is that the initialization functions are smarter and know exactly what within the structures needs to be zeroed as opposed to blindly clearing everything. So, for example, large byte arrays used to hold OCTET STRING data will not be zeroed. This can add up to significant performance improvements in the long run, particular in complex, deeply-nested ASN.1 types.

If initialization functions are generated, the generated decode logic will use them wherever it can in place of calls to zero memory.