From cde2b8bac620caf3858ccab16e82005b3ef27bee Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Sat, 13 Dec 2014 07:50:34 +0000 Subject: datatype: generate name for concat types The name of a concat type is the names of the individual types concatenated using a '.'. Signed-off-by: Patrick McHardy --- src/datatype.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/datatype.c') diff --git a/src/datatype.c b/src/datatype.c index 7f730776..807b0f18 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -928,12 +928,16 @@ const struct datatype *concat_type_alloc(const struct expr *expr) struct datatype *dtype; struct expr *i; char desc[256] = "concatenation of ("; + char name[256] = ""; unsigned int type = 0, size = 0; list_for_each_entry(i, &expr->expressions, list) { - if (size != 0) + if (size != 0) { strncat(desc, ", ", sizeof(desc) - strlen(desc) - 1); + strncat(name, " . ", sizeof(name) - strlen(name) - 1); + } strncat(desc, i->dtype->desc, sizeof(desc) - strlen(desc) - 1); + strncat(name, i->dtype->name, sizeof(name) - strlen(name) - 1); type <<= 8; type |= i->dtype->type; @@ -944,6 +948,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr) dtype = dtype_alloc(); dtype->type = type; dtype->size = size; + dtype->name = xstrdup(name); dtype->desc = xstrdup(desc); dtype->parse = concat_type_parse; @@ -953,6 +958,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr) void concat_type_destroy(const struct datatype *dtype) { if (dtype->flags & DTYPE_F_ALLOC) { + xfree(dtype->name); xfree(dtype->desc); xfree(dtype); } -- cgit v1.2.3