From 5cc18d46f334e15e2d0d62d4be9e06b27e928d7a Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER Date: Wed, 19 Aug 2015 09:02:36 +0200 Subject: [PATCH] MINOR: samples: data assignation simplification With the difference between the "struct sample" data and the "struct sample_storage" data, it was not possible to write data = data, and we did a memcpy. This patch remove some of these memcpy. --- src/map.c | 3 +-- src/vars.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/map.c b/src/map.c index 73e057ed6..577d4187c 100644 --- a/src/map.c +++ b/src/map.c @@ -161,9 +161,8 @@ static int sample_conv_map(const struct arg *arg_p, struct sample *smp, void *pr if (pat) { /* Copy sample. */ if (pat->data) { - smp->data.type = pat->data->type; + smp->data = *pat->data; smp->flags |= SMP_F_CONST; - memcpy(&smp->data.u, &pat->data->u, sizeof(smp->data.u)); return 1; } diff --git a/src/vars.c b/src/vars.c index ed30846bf..3ad0c1694 100644 --- a/src/vars.c +++ b/src/vars.c @@ -249,9 +249,8 @@ static int smp_fetch_var(const struct arg *args, struct sample *smp, const char return 0; /* Copy sample. */ - smp->data.type = var->data.type; + smp->data = var->data; smp->flags |= SMP_F_CONST; - memcpy(&smp->data.u, &var->data.u, sizeof(smp->data.u)); return 1; } @@ -442,9 +441,8 @@ int vars_get_by_name(const char *name, size_t len, struct stream *strm, struct s return 0; /* Copy sample. */ - smp->data.type = var->data.type; + smp->data = var->data; smp->flags = SMP_F_CONST; - memcpy(&smp->data.u, &var->data.u, sizeof(smp->data.u)); return 1; } @@ -476,9 +474,8 @@ int vars_get_by_desc(const struct var_desc *var_desc, struct stream *strm, struc return 0; /* Copy sample. */ - smp->data.type = var->data.type; + smp->data = var->data; smp->flags = SMP_F_CONST; - memcpy(&smp->data.u, &var->data.u, sizeof(smp->data.u)); return 1; }