Index: ltrace-0.7.91+git20230705.8eabf68/expr.c =================================================================== --- ltrace-0.7.91+git20230705.8eabf68.orig/expr.c +++ ltrace-0.7.91+git20230705.8eabf68/expr.c @@ -171,89 +171,6 @@ expr_destroy(struct expr_node *node) abort(); } -static int -expr_alloc_and_clone(struct expr_node **retpp, struct expr_node *node, int own) -{ - *retpp = node; - if (own) { - *retpp = malloc(sizeof **retpp); - if (*retpp == NULL || expr_clone(*retpp, node) < 0) { - free(*retpp); - return -1; - } - } - return 0; -} - -int -expr_clone(struct expr_node *retp, const struct expr_node *node) -{ - struct expr_node *nlhs; - /* Must be a known value to distinguish EXPR_OP_CALL2 - from EXPR_OP_CALL1 or EXPR_OP_UP. */ - struct expr_node *nrhs = NULL; - - *retp = *node; - - switch (node->kind) { - - case EXPR_OP_ARGNO: - case EXPR_OP_SELF: - return 0; - - case EXPR_OP_CONST: - return value_clone(&retp->u.value, &node->u.value); - - case EXPR_OP_NAMED: - if (node->u.name.own - && (retp->u.name.s = strdup(node->u.name.s)) == NULL) - return -1; - return 0; - - case EXPR_OP_INDEX: - if (expr_alloc_and_clone(&nlhs, node->lhs, node->own_lhs) < 0) - return -1; - - if (expr_alloc_and_clone(&nrhs, node->u.node.n, - node->u.node.own) < 0) { - if (nlhs != node->lhs) { - expr_destroy(nlhs); - free(nlhs); - } - return -1; - } - - retp->lhs = nlhs; - retp->u.node.n = nrhs; - return 0; - - case EXPR_OP_CALL2: - if (expr_alloc_and_clone(&nrhs, node->u.call.rhs, - node->u.call.own_rhs) < 0) - return -1; - retp->u.call.rhs = nrhs; - /* Fall through. */ - - case EXPR_OP_UP: - case EXPR_OP_CALL1: - if (expr_alloc_and_clone(&nlhs, node->lhs, node->own_lhs) < 0) { - if (node->kind == EXPR_OP_CALL2 - && node->u.call.own_rhs - && nrhs != NULL) { - expr_destroy(nrhs); - free(nrhs); - return -1; - } - } - - retp->lhs = nlhs; - return 0; - } - - assert(!"Invalid value of node kind"); - abort(); -} - int expr_is_compile_constant(struct expr_node *node) { Index: ltrace-0.7.91+git20230705.8eabf68/expr.h =================================================================== --- ltrace-0.7.91+git20230705.8eabf68.orig/expr.h +++ ltrace-0.7.91+git20230705.8eabf68/expr.h @@ -125,9 +125,6 @@ void expr_init_cb2(struct expr_node *nod /* Release the data inside NODE. Doesn't free NODE itself. */ void expr_destroy(struct expr_node *node); -/* Copy expression NODE into the area pointed to by RETP. Return 0 on - * success or a negative value on failure. */ -int expr_clone(struct expr_node *retp, const struct expr_node *node); /* Evaluate the expression NODE in context of VALUE. ARGUMENTS is a * dictionary of named and numbered values that NODE may use. Returns