summaryrefslogtreecommitdiffstats
path: root/src/datatype.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2014-12-13 07:50:34 +0000
committerPatrick McHardy <kaber@trash.net>2014-12-16 18:20:54 +0100
commit0b915d6dc50e9e5aeb3e41db9d20dc96d9edee3f (patch)
tree01279cb6d61e81e916017e2406afa82ddf9f002a /src/datatype.c
parentcde2b8bac620caf3858ccab16e82005b3ef27bee (diff)
datatype: add new subtypes field to account number of concat data types
Using the size is confusing since it usually holds the size of the data. Add a new "subtypes" member, which holds the number of datatypes the concat type is made of. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/datatype.c')
-rw-r--r--src/datatype.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/datatype.c b/src/datatype.c
index 807b0f18..8583531f 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -929,10 +929,10 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
struct expr *i;
char desc[256] = "concatenation of (";
char name[256] = "";
- unsigned int type = 0, size = 0;
+ unsigned int type = 0, size = 0, subtypes = 0;
list_for_each_entry(i, &expr->expressions, list) {
- if (size != 0) {
+ if (subtypes != 0) {
strncat(desc, ", ", sizeof(desc) - strlen(desc) - 1);
strncat(name, " . ", sizeof(name) - strlen(name) - 1);
}
@@ -941,13 +941,15 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
type <<= 8;
type |= i->dtype->type;
- size++;
+ size += i->dtype->size;
+ subtypes++;
}
strncat(desc, ")", sizeof(desc) - strlen(desc) - 1);
dtype = dtype_alloc();
dtype->type = type;
dtype->size = size;
+ dtype->subtypes = subtypes;
dtype->name = xstrdup(name);
dtype->desc = xstrdup(desc);
dtype->parse = concat_type_parse;