summaryrefslogtreecommitdiffstats
path: root/src/datatype.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datatype.c')
-rw-r--r--src/datatype.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/datatype.c b/src/datatype.c
index 2cb937f5..ca6c92f5 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -658,6 +658,16 @@ static struct error_record *concat_type_parse(const struct expr *sym,
sym->dtype->desc);
}
+static struct datatype *dtype_alloc(void)
+{
+ struct datatype *dtype;
+
+ dtype = xzalloc(sizeof(*dtype));
+ dtype->flags = DTYPE_F_ALLOC;
+
+ return dtype;
+}
+
const struct datatype *concat_type_alloc(const struct expr *expr)
{
struct datatype *dtype;
@@ -676,7 +686,7 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
}
strncat(desc, ")", sizeof(desc) - strlen(desc) - 1);
- dtype = xzalloc(sizeof(*dtype));
+ dtype = dtype_alloc();
dtype->type = type;
dtype->size = size;
dtype->desc = xstrdup(desc);
@@ -687,5 +697,6 @@ const struct datatype *concat_type_alloc(const struct expr *expr)
void concat_type_destroy(const struct datatype *dtype)
{
- xfree(dtype);
+ if (dtype->flags & DTYPE_F_ALLOC)
+ xfree(dtype);
}