Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions include/simics/dmllib.h
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,15 @@ _DML_get_qname(_identity_t id, const _id_info_t *id_infos,
return qname;
}

void
_DML_free_qname_cache(qname_cache_t *cache)
{
for (int i = 0; i < 4; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this magic 4 be a define?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizeof(cache->bufs)/sizeof(cache->bufs[0]) is also a pretty common C pattern (though typically broken out to a macro)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works for me too, I wasn't sure if cache->bufs was an array or pointer

MM_FREE(cache->bufs[i]);
cache->bufs[i] = NULL;
}
}

static inline int
DML_pointer_eq(lang_void *data, lang_void *match_data)
{ return data == match_data; }
Expand Down
6 changes: 5 additions & 1 deletion lib/1.4/dml-builtins.dml
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,10 @@ template device {

method _init() { _rec_init(); }
method _post_init() { _rec_post_init(); }
method _destroy() { _rec_destroy(); }
method _destroy() {
_rec_destroy();
_DML_free_qname_cache();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing its argument.

}
method init() default {}
method post_init() default {}
method destroy() default {}
Expand Down Expand Up @@ -3735,6 +3738,7 @@ template init_val is init {

extern const char *_DML_get_qname(_identity_t, const _id_info_t *,
dml_qname_cache_t *, const char *);
extern void _DML_free_qname_cache(dml_qname_cache_t *);
template _qname {
shared method _qname() -> (const char *) {
local _qname ref = this;
Expand Down