MCPcopy Create free account
hub / github.com/ElementsProject/lightning / configvar_remove

Function configvar_remove

common/configvar.c:129–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void configvar_remove(struct configvar ***cvs,
130 const char *name,
131 enum configvar_src src,
132 const char *optarg)
133{
134 /* We remove all from this source, potentially restoring an overridden */
135 ssize_t prev = -1;
136 bool removed;
137
138 removed = false;
139 for (size_t i = 0; i < tal_count(*cvs); i++) {
140 /* This can happen if plugin fails during startup! */
141 if ((*cvs)[i]->optvar == NULL)
142 continue;
143 if (!streq((*cvs)[i]->optvar, name))
144 continue;
145 if (optarg && !streq((*cvs)[i]->optarg, optarg))
146 continue;
147
148 if ((*cvs)[i]->src == src) {
149 tal_free((*cvs)[i]);
150 tal_arr_remove(cvs, i);
151 i--;
152 removed = true;
153 continue;
154 }
155 /* Wrong type, correct name. */
156 prev = i;
157 }
158
159 /* Unmark prev if we removed overriding ones. If it's multi,
160 * this is a noop. */
161 if (removed && prev != -1)
162 (*cvs)[prev]->overridden = false;
163}
164
165struct configvar *configvar_dup(const tal_t *ctx, const struct configvar *cv)
166{

Callers 3

destroy_plugin_optFunction · 0.85
configvar_save_multiFunction · 0.85
setconfig_successFunction · 0.85

Calls 1

tal_freeFunction · 0.85

Tested by

no test coverage detected