aboutsummaryrefslogtreecommitdiff
path: root/expr.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-12-08 03:13:29 +0100
committerPetr Machata <pmachata@redhat.com>2012-12-10 11:48:58 +0100
commit1233b37167097dffa9a78bd7bd0a8117c75fe8ff (patch)
tree0fce5991a8be6897f7791301d296c3fa66429c91 /expr.c
parentd66c8b11facf570d96a49c1b812b90101c62023b (diff)
downloadltrace-1233b37167097dffa9a78bd7bd0a8117c75fe8ff.tar.gz
expr_node_zero and expr_self should be stack-allocated
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/expr.c b/expr.c
index 32860fd..552a53c 100644
--- a/expr.c
+++ b/expr.c
@@ -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;
}