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

Function configvar_remove

common/configvar.c:134–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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