For example, there are many 'enum value_PR' and 'struct value' generated if
a class is instantiated as many instances.
typedef enum value_PR {
value_PR_NOTHING, /* No components present */
.....
} value_PR;
typedef struct ProtocolIE_Field_6563P5 {
....
struct value {
value_PR present;
union value_u {
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} value;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} ProtocolIE_Field_6563P5_t;
1. Add 'ref_cnt' field to asn1p_expr_t.
2. Initialize 'ref_cnt' field to zero when asn1p_expr_t is allocated.
3. Increase 'ref_cnt' field when asn1p_expr_t is cloned by asn1p_value_fromtype().
4. If 'ref_cnt' field of asn1p_expr_t is larger than zero, then asn1p_expr_free() only decrease its value.
5. Free memory pointed by fields of asn1p_expr_t and itself when 'ref_cnt' is zero and asn1p_expr_free() called.
6. Call asn1p_delete(asn) in main().
The following functions return immediately if a null pointer was passed.
* asn1p_constraint_free
* asn1p_paramlist_free
* asn1p_ref_free
* asn1p_value_free
* asn1p_wsyntx_free
It is therefore not needed that a function caller repeats a corresponding check.
This issue was fixed by using the software "Coccinelle 1.0.4".
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>