blob: d430844e046aa7c8b4e824229fca18dfbd3c1d3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#include <stdlib.h>
#include <string.h>
#include "asn1parser.h"
/*
* Construct a new empty module.
*/
asn1p_module_t *
asn1p_module_new() {
asn1p_module_t *mod;
mod = calloc(1, sizeof *mod);
if(mod) {
TQ_INIT(&(mod->imports));
TQ_INIT(&(mod->exports));
TQ_INIT(&(mod->members));
}
return mod;
}
/*
* Destroy the module.
*/
void
asn1p_module_free(asn1p_module_t *mod) {
if(mod) {
asn1p_expr_t *expr;
if(mod->Identifier)
free(mod->Identifier);
if(mod->module_oid)
asn1p_oid_free(mod->module_oid);
while((expr = TQ_REMOVE(&(mod->members), next)))
asn1p_expr_free(expr);
free(mod);
}
}
asn1p_t *
asn1p_new() {
asn1p_t *asn;
asn = calloc(1, sizeof(*asn));
if(asn) {
TQ_INIT(&(asn->modules));
}
return asn;
}
void
asn1p_free(asn1p_t *asn) {
if(asn) {
asn1p_module_t *mod;
while((mod = TQ_REMOVE(&(asn->modules), mod_next)))
asn1p_module_free(mod);
free(asn);
}
}
|