Deep-copy a binding (so source and dest own separate string copies) */
| 2508 | |
| 2509 | /* Deep-copy a binding (so source and dest own separate string copies) */ |
| 2510 | static void binding_copy(binding_t *dst, const binding_t *src) { |
| 2511 | dst->var_count = src->var_count; |
| 2512 | for (int i = 0; i < src->var_count; i++) { |
| 2513 | dst->var_names[i] = src->var_names[i]; /* AST-owned, not freed */ |
| 2514 | node_deep_copy(&dst->var_nodes[i], &src->var_nodes[i]); |
| 2515 | } |
| 2516 | dst->edge_var_count = src->edge_var_count; |
| 2517 | for (int i = 0; i < src->edge_var_count; i++) { |
| 2518 | dst->edge_var_names[i] = src->edge_var_names[i]; /* AST-owned */ |
| 2519 | edge_deep_copy(&dst->edge_vars[i], &src->edge_vars[i]); |
| 2520 | } |
| 2521 | dst->store = src->store; |
| 2522 | } |
| 2523 | |
| 2524 | /* Deep-copy a node into a binding (binding owns the strings) */ |
| 2525 | static void binding_set(binding_t *b, const char *var, const cbm_node_t *node) { |
no test coverage detected