SIM-115: update simulator to use latest E2SM KPM version 3
[sim/e2-interface.git] / e2sim / asn1c / asn_codecs_prim.c
1 /*-
2  * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #include <asn_internal.h>
6 #include <asn_codecs_prim.h>
7
8 void
9 ASN__PRIMITIVE_TYPE_free(const asn_TYPE_descriptor_t *td, void *sptr,
10                          enum asn_struct_free_method method) {
11     ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr;
12
13         if(!td || !sptr)
14                 return;
15
16         ASN_DEBUG("Freeing %s as a primitive type", td->name);
17
18         if(st->buf)
19                 FREEMEM(st->buf);
20
21     switch(method) {
22     case ASFM_FREE_EVERYTHING:
23         FREEMEM(sptr);
24         break;
25     case ASFM_FREE_UNDERLYING:
26         break;
27     case ASFM_FREE_UNDERLYING_AND_RESET:
28         memset(sptr, 0, sizeof(ASN__PRIMITIVE_TYPE_t));
29         break;
30     }
31 }