Skip to content

Commit 99f1700

Browse files
committed
dmllib.h: Add function to calculate _qname independently
I've found myself wanting this multiple times while working on DDM. We're keeping this a purely internal change -- one way I'm limiting its exposure is by intentionally not `extern`ing the new function within dml-builtins.
1 parent 926d8c4 commit 99f1700

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

include/simics/dmllib.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,21 +2256,21 @@ __qname(dml_qname_cache_t *cache, const char *fmt, ...)
22562256
return (const char *)s;
22572257
}
22582258

2259-
UNUSED static const char *
2260-
_DML_get_qname(_identity_t id, const _id_info_t *id_infos,
2261-
dml_qname_cache_t *cache, const char *dev_name) {
2259+
UNUSED static char *
2260+
_DML_get_qname_alloc(_identity_t id, const _id_info_t *id_infos,
2261+
const char *dev_name) {
22622262
_id_info_t info = id_infos[id.id - 1];
22632263

22642264
const char *logname = info.logname;
22652265

22662266
// In order to distinguish the device object from any other, its id_info
22672267
// logname is always "dev", but we want its name when it comes to qname.
22682268
if (strcmp(logname, "dev") == 0) {
2269-
return dev_name;
2269+
return MM_STRDUP(dev_name);
22702270
}
22712271

22722272
if (info.dimensions == 0) {
2273-
return logname;
2273+
return MM_STRDUP(logname);
22742274
}
22752275

22762276
uint32 indices[info.dimensions];
@@ -2280,7 +2280,13 @@ _DML_get_qname(_identity_t id, const _id_info_t *id_infos,
22802280
index /= info.dimsizes[i];
22812281
}
22822282

2283-
char *temp_qname = _DML_format_indices(logname, indices, info.dimensions);
2283+
return _DML_format_indices(logname, indices, info.dimensions);
2284+
}
2285+
2286+
UNUSED static const char *
2287+
_DML_get_qname(_identity_t id, const _id_info_t *id_infos,
2288+
dml_qname_cache_t *cache, const char *dev_name) {
2289+
char *temp_qname = _DML_get_qname_alloc(id, id_infos, dev_name);
22842290
const char *qname = __qname(cache, "%s", temp_qname);
22852291
MM_FREE(temp_qname);
22862292
return qname;

0 commit comments

Comments
 (0)