MCPcopy Create free account
hub / github.com/Entware/Entware / expr_copy

Function expr_copy

scripts/config/expr.c:66–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66struct expr *expr_copy(const struct expr *org)
67{
68 struct expr *e;
69
70 if (!org)
71 return NULL;
72
73 e = xmalloc(sizeof(*org));
74 memcpy(e, org, sizeof(*org));
75 switch (org->type) {
76 case E_SYMBOL:
77 e->left = org->left;
78 break;
79 case E_NOT:
80 e->left.expr = expr_copy(org->left.expr);
81 break;
82 case E_EQUAL:
83 case E_GEQ:
84 case E_GTH:
85 case E_LEQ:
86 case E_LTH:
87 case E_UNEQUAL:
88 e->left.sym = org->left.sym;
89 e->right.sym = org->right.sym;
90 break;
91 case E_AND:
92 case E_OR:
93 case E_LIST:
94 e->left.expr = expr_copy(org->left.expr);
95 e->right.expr = expr_copy(org->right.expr);
96 break;
97 default:
98 fprintf(stderr, "can't copy type %d\n", e->type);
99 free(e);
100 e = NULL;
101 break;
102 }
103
104 return e;
105}
106
107void expr_free(struct expr *e)
108{

Callers 6

expr_eqFunction · 0.85
expr_join_orFunction · 0.85
expr_join_andFunction · 0.85
expr_trans_compareFunction · 0.85
menu_add_promptFunction · 0.85
menu_finalizeFunction · 0.85

Calls 1

xmallocFunction · 0.85

Tested by

no test coverage detected