diff options
author | Petr Machata <pmachata@redhat.com> | 2012-12-08 03:13:29 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-12-10 11:48:58 +0100 |
commit | 1233b37167097dffa9a78bd7bd0a8117c75fe8ff (patch) | |
tree | 0fce5991a8be6897f7791301d296c3fa66429c91 /expr.c | |
parent | d66c8b11facf570d96a49c1b812b90101c62023b (diff) | |
download | ltrace-1233b37167097dffa9a78bd7bd0a8117c75fe8ff.tar.gz |
expr_node_zero and expr_self should be stack-allocated
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -21,7 +21,6 @@ #include <string.h> #include <assert.h> #include <errno.h> -#include <error.h> #include <stdlib.h> #include "expr.h" @@ -327,12 +326,11 @@ expr_eval_constant(struct expr_node *node, long *valuep) struct expr_node * expr_self(void) { - static struct expr_node *node = NULL; - if (node == NULL) { - node = malloc(sizeof(*node)); - if (node == NULL) - error(1, errno, "malloc expr_self"); - expr_init_self(node); + static struct expr_node *nodep = NULL; + if (nodep == NULL) { + static struct expr_node node; + expr_init_self(&node); + nodep = &node; } - return node; + return nodep; } |