]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: samples: data assignation simplification
authorThierry FOURNIER <tfournier@arpalert.org>
Wed, 19 Aug 2015 07:02:36 +0000 (09:02 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Aug 2015 15:13:46 +0000 (17:13 +0200)
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
src/vars.c

index 73e057ed69c13403cd02105ca86a1504b10bfc54..577d4187cc80af2667b7d8a70d3bae1092c126ac 100644 (file)
--- 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;
                }
 
index ed30846bf5040cc6c55f8171208562f391df9c90..3ad0c169478c5c463f7399fad0d03e882c693f0c 100644 (file)
@@ -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;
 }