Commit 9b780838 authored by Bi-Ruei, Chiu's avatar Bi-Ruei, Chiu

Free memory allocated in asn1c_compiled_output() and asn1c_lang_C_type_SEx_OF_def()

parent 12021b53
......@@ -813,6 +813,8 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
arg->embed++;
emit_member_table(arg, v);
arg->embed--;
free(v->Identifier);
v->Identifier = (char *)NULL;
INDENT(-1);
OUT("};\n");
......
......@@ -6,6 +6,7 @@
static void default_logger_cb(int, const char *fmt, ...);
static int asn1c_compile_expr(arg_t *arg);
static int asn1c_attach_streams(asn1p_expr_t *expr);
static int asn1c_detach_streams(asn1p_expr_t *expr);
int
asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
......@@ -61,6 +62,12 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
if(asn1c_save_compiled_output(arg, datadir, argc, optc, argv))
return -1;
TQ_FOR(mod, &(asn->modules), mod_next) {
TQ_FOR(arg->expr, &(mod->members), next) {
asn1c_detach_streams(arg->expr);
}
}
return 0;
}
......@@ -159,6 +166,28 @@ asn1c_attach_streams(asn1p_expr_t *expr) {
return 0;
}
int
asn1c_detach_streams(asn1p_expr_t *expr) {
compiler_streams_t *cs;
out_chunk_t *m;
int i;
if(!expr->data)
return 0; /* Already detached? */
cs = expr->data;
for(i = 0; i < OT_MAX; i++) {
while((m = TQ_REMOVE(&(cs->destination[i].chunks), next))) {
free(m->buf);
free(m);
}
}
free(expr->data);
expr->data = (void *)NULL;
return 0;
}
static void
default_logger_cb(int _severity, const char *fmt, ...) {
va_list ap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment