Commit 47fc74ca authored by Lev Walkin's avatar Lev Walkin

proper destruction of a name storage

parent ef8dd441
......@@ -17,6 +17,24 @@ c_name_clash_finder_init() {
TQ_INIT(&used_names);
}
void
c_name_clash_finder_destroy() {
struct intl_name *n;
while((n = TQ_REMOVE(&used_names, next))) {
union {
const char *c_buf;
char *nc_buf;
} const_cast;
asn1p_expr_free(n->expr);
asn1p_expr_free(n->clashes_with);
const_cast.c_buf = n->name;
free(const_cast.nc_buf);
free(n);
}
}
static void
register_global_name(arg_t *arg, const char *name) {
struct intl_name *n;
......@@ -25,14 +43,19 @@ register_global_name(arg_t *arg, const char *name) {
if(strcmp(n->name, name) == 0) {
if(!(arg->expr->_mark & TM_NAMEGIVEN) && arg->expr != n->expr) {
n->clashes_with = arg->expr;
arg->expr->ref_cnt++;
return;
}
}
}
if(arg->expr->_mark & TM_NAMEGIVEN)
return;
n = calloc(1, sizeof(*n));
assert(n);
n->expr = arg->expr;
arg->expr->ref_cnt++;
n->name = strdup(name);
TQ_ADD(&used_names, n, next);
}
......
......@@ -25,4 +25,6 @@ int c_name_clash(arg_t *arg);
void c_name_clash_finder_init(void);
void c_name_clash_finder_destroy(void);
#endif /* ASN1_COMPILER_NAMING_H */
......@@ -79,6 +79,8 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
DEBUG("Saving compiled data");
c_name_clash_finder_destroy();
/*
* Save or print out the compiled result.
*/
......
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