1*11be35a1SLionel Sambuc /*
2*11be35a1SLionel Sambuc * Automated Testing Framework (atf)
3*11be35a1SLionel Sambuc *
4*11be35a1SLionel Sambuc * Copyright (c) 2008 The NetBSD Foundation, Inc.
5*11be35a1SLionel Sambuc * All rights reserved.
6*11be35a1SLionel Sambuc *
7*11be35a1SLionel Sambuc * Redistribution and use in source and binary forms, with or without
8*11be35a1SLionel Sambuc * modification, are permitted provided that the following conditions
9*11be35a1SLionel Sambuc * are met:
10*11be35a1SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
11*11be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer.
12*11be35a1SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
13*11be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
14*11be35a1SLionel Sambuc * documentation and/or other materials provided with the distribution.
15*11be35a1SLionel Sambuc *
16*11be35a1SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17*11be35a1SLionel Sambuc * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18*11be35a1SLionel Sambuc * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19*11be35a1SLionel Sambuc * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20*11be35a1SLionel Sambuc * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21*11be35a1SLionel Sambuc * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*11be35a1SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23*11be35a1SLionel Sambuc * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*11be35a1SLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25*11be35a1SLionel Sambuc * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26*11be35a1SLionel Sambuc * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27*11be35a1SLionel Sambuc * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*11be35a1SLionel Sambuc */
29*11be35a1SLionel Sambuc
30*11be35a1SLionel Sambuc #include <errno.h>
31*11be35a1SLionel Sambuc #include <stdlib.h>
32*11be35a1SLionel Sambuc #include <string.h>
33*11be35a1SLionel Sambuc
34*11be35a1SLionel Sambuc #include "atf-c/error.h"
35*11be35a1SLionel Sambuc #include "atf-c/utils.h"
36*11be35a1SLionel Sambuc
37*11be35a1SLionel Sambuc #include "map.h"
38*11be35a1SLionel Sambuc #include "sanity.h"
39*11be35a1SLionel Sambuc
40*11be35a1SLionel Sambuc /* ---------------------------------------------------------------------
41*11be35a1SLionel Sambuc * Auxiliary functions.
42*11be35a1SLionel Sambuc * --------------------------------------------------------------------- */
43*11be35a1SLionel Sambuc
44*11be35a1SLionel Sambuc struct map_entry {
45*11be35a1SLionel Sambuc char *m_key;
46*11be35a1SLionel Sambuc void *m_value;
47*11be35a1SLionel Sambuc bool m_managed;
48*11be35a1SLionel Sambuc };
49*11be35a1SLionel Sambuc
50*11be35a1SLionel Sambuc static
51*11be35a1SLionel Sambuc struct map_entry *
new_entry(const char * key,void * value,bool managed)52*11be35a1SLionel Sambuc new_entry(const char *key, void *value, bool managed)
53*11be35a1SLionel Sambuc {
54*11be35a1SLionel Sambuc struct map_entry *me;
55*11be35a1SLionel Sambuc
56*11be35a1SLionel Sambuc me = (struct map_entry *)malloc(sizeof(*me));
57*11be35a1SLionel Sambuc if (me != NULL) {
58*11be35a1SLionel Sambuc me->m_key = strdup(key);
59*11be35a1SLionel Sambuc if (me->m_key == NULL) {
60*11be35a1SLionel Sambuc free(me);
61*11be35a1SLionel Sambuc me = NULL;
62*11be35a1SLionel Sambuc } else {
63*11be35a1SLionel Sambuc me->m_value = value;
64*11be35a1SLionel Sambuc me->m_managed = managed;
65*11be35a1SLionel Sambuc }
66*11be35a1SLionel Sambuc }
67*11be35a1SLionel Sambuc
68*11be35a1SLionel Sambuc return me;
69*11be35a1SLionel Sambuc }
70*11be35a1SLionel Sambuc
71*11be35a1SLionel Sambuc /* ---------------------------------------------------------------------
72*11be35a1SLionel Sambuc * The "atf_map_citer" type.
73*11be35a1SLionel Sambuc * --------------------------------------------------------------------- */
74*11be35a1SLionel Sambuc
75*11be35a1SLionel Sambuc /*
76*11be35a1SLionel Sambuc * Getters.
77*11be35a1SLionel Sambuc */
78*11be35a1SLionel Sambuc
79*11be35a1SLionel Sambuc const char *
atf_map_citer_key(const atf_map_citer_t citer)80*11be35a1SLionel Sambuc atf_map_citer_key(const atf_map_citer_t citer)
81*11be35a1SLionel Sambuc {
82*11be35a1SLionel Sambuc const struct map_entry *me = citer.m_entry;
83*11be35a1SLionel Sambuc PRE(me != NULL);
84*11be35a1SLionel Sambuc return me->m_key;
85*11be35a1SLionel Sambuc }
86*11be35a1SLionel Sambuc
87*11be35a1SLionel Sambuc const void *
atf_map_citer_data(const atf_map_citer_t citer)88*11be35a1SLionel Sambuc atf_map_citer_data(const atf_map_citer_t citer)
89*11be35a1SLionel Sambuc {
90*11be35a1SLionel Sambuc const struct map_entry *me = citer.m_entry;
91*11be35a1SLionel Sambuc PRE(me != NULL);
92*11be35a1SLionel Sambuc return me->m_value;
93*11be35a1SLionel Sambuc }
94*11be35a1SLionel Sambuc
95*11be35a1SLionel Sambuc atf_map_citer_t
atf_map_citer_next(const atf_map_citer_t citer)96*11be35a1SLionel Sambuc atf_map_citer_next(const atf_map_citer_t citer)
97*11be35a1SLionel Sambuc {
98*11be35a1SLionel Sambuc atf_map_citer_t newciter;
99*11be35a1SLionel Sambuc
100*11be35a1SLionel Sambuc newciter = citer;
101*11be35a1SLionel Sambuc newciter.m_listiter = atf_list_citer_next(citer.m_listiter);
102*11be35a1SLionel Sambuc newciter.m_entry = ((const struct map_entry *)
103*11be35a1SLionel Sambuc atf_list_citer_data(newciter.m_listiter));
104*11be35a1SLionel Sambuc
105*11be35a1SLionel Sambuc return newciter;
106*11be35a1SLionel Sambuc }
107*11be35a1SLionel Sambuc
108*11be35a1SLionel Sambuc bool
atf_equal_map_citer_map_citer(const atf_map_citer_t i1,const atf_map_citer_t i2)109*11be35a1SLionel Sambuc atf_equal_map_citer_map_citer(const atf_map_citer_t i1,
110*11be35a1SLionel Sambuc const atf_map_citer_t i2)
111*11be35a1SLionel Sambuc {
112*11be35a1SLionel Sambuc return i1.m_map == i2.m_map && i1.m_entry == i2.m_entry;
113*11be35a1SLionel Sambuc }
114*11be35a1SLionel Sambuc
115*11be35a1SLionel Sambuc /* ---------------------------------------------------------------------
116*11be35a1SLionel Sambuc * The "atf_map_iter" type.
117*11be35a1SLionel Sambuc * --------------------------------------------------------------------- */
118*11be35a1SLionel Sambuc
119*11be35a1SLionel Sambuc /*
120*11be35a1SLionel Sambuc * Getters.
121*11be35a1SLionel Sambuc */
122*11be35a1SLionel Sambuc
123*11be35a1SLionel Sambuc const char *
atf_map_iter_key(const atf_map_iter_t iter)124*11be35a1SLionel Sambuc atf_map_iter_key(const atf_map_iter_t iter)
125*11be35a1SLionel Sambuc {
126*11be35a1SLionel Sambuc const struct map_entry *me = iter.m_entry;
127*11be35a1SLionel Sambuc PRE(me != NULL);
128*11be35a1SLionel Sambuc return me->m_key;
129*11be35a1SLionel Sambuc }
130*11be35a1SLionel Sambuc
131*11be35a1SLionel Sambuc void *
atf_map_iter_data(const atf_map_iter_t iter)132*11be35a1SLionel Sambuc atf_map_iter_data(const atf_map_iter_t iter)
133*11be35a1SLionel Sambuc {
134*11be35a1SLionel Sambuc const struct map_entry *me = iter.m_entry;
135*11be35a1SLionel Sambuc PRE(me != NULL);
136*11be35a1SLionel Sambuc return me->m_value;
137*11be35a1SLionel Sambuc }
138*11be35a1SLionel Sambuc
139*11be35a1SLionel Sambuc atf_map_iter_t
atf_map_iter_next(const atf_map_iter_t iter)140*11be35a1SLionel Sambuc atf_map_iter_next(const atf_map_iter_t iter)
141*11be35a1SLionel Sambuc {
142*11be35a1SLionel Sambuc atf_map_iter_t newiter;
143*11be35a1SLionel Sambuc
144*11be35a1SLionel Sambuc newiter = iter;
145*11be35a1SLionel Sambuc newiter.m_listiter = atf_list_iter_next(iter.m_listiter);
146*11be35a1SLionel Sambuc newiter.m_entry = ((struct map_entry *)
147*11be35a1SLionel Sambuc atf_list_iter_data(newiter.m_listiter));
148*11be35a1SLionel Sambuc
149*11be35a1SLionel Sambuc return newiter;
150*11be35a1SLionel Sambuc }
151*11be35a1SLionel Sambuc
152*11be35a1SLionel Sambuc bool
atf_equal_map_iter_map_iter(const atf_map_iter_t i1,const atf_map_iter_t i2)153*11be35a1SLionel Sambuc atf_equal_map_iter_map_iter(const atf_map_iter_t i1,
154*11be35a1SLionel Sambuc const atf_map_iter_t i2)
155*11be35a1SLionel Sambuc {
156*11be35a1SLionel Sambuc return i1.m_map == i2.m_map && i1.m_entry == i2.m_entry;
157*11be35a1SLionel Sambuc }
158*11be35a1SLionel Sambuc
159*11be35a1SLionel Sambuc /* ---------------------------------------------------------------------
160*11be35a1SLionel Sambuc * The "atf_map" type.
161*11be35a1SLionel Sambuc * --------------------------------------------------------------------- */
162*11be35a1SLionel Sambuc
163*11be35a1SLionel Sambuc /*
164*11be35a1SLionel Sambuc * Constructors and destructors.
165*11be35a1SLionel Sambuc */
166*11be35a1SLionel Sambuc
167*11be35a1SLionel Sambuc atf_error_t
atf_map_init(atf_map_t * m)168*11be35a1SLionel Sambuc atf_map_init(atf_map_t *m)
169*11be35a1SLionel Sambuc {
170*11be35a1SLionel Sambuc return atf_list_init(&m->m_list);
171*11be35a1SLionel Sambuc }
172*11be35a1SLionel Sambuc
173*11be35a1SLionel Sambuc atf_error_t
atf_map_init_charpp(atf_map_t * m,const char * const * array)174*11be35a1SLionel Sambuc atf_map_init_charpp(atf_map_t *m, const char *const *array)
175*11be35a1SLionel Sambuc {
176*11be35a1SLionel Sambuc atf_error_t err;
177*11be35a1SLionel Sambuc const char *const *ptr = array;
178*11be35a1SLionel Sambuc
179*11be35a1SLionel Sambuc err = atf_map_init(m);
180*11be35a1SLionel Sambuc if (array != NULL) {
181*11be35a1SLionel Sambuc while (!atf_is_error(err) && *ptr != NULL) {
182*11be35a1SLionel Sambuc const char *key, *value;
183*11be35a1SLionel Sambuc
184*11be35a1SLionel Sambuc key = *ptr;
185*11be35a1SLionel Sambuc INV(key != NULL);
186*11be35a1SLionel Sambuc ptr++;
187*11be35a1SLionel Sambuc
188*11be35a1SLionel Sambuc if ((value = *ptr) == NULL) {
189*11be35a1SLionel Sambuc err = atf_libc_error(EINVAL, "List too short; no value for "
190*11be35a1SLionel Sambuc "key '%s' provided", key); /* XXX: Not really libc_error */
191*11be35a1SLionel Sambuc break;
192*11be35a1SLionel Sambuc }
193*11be35a1SLionel Sambuc ptr++;
194*11be35a1SLionel Sambuc
195*11be35a1SLionel Sambuc err = atf_map_insert(m, key, strdup(value), true);
196*11be35a1SLionel Sambuc }
197*11be35a1SLionel Sambuc }
198*11be35a1SLionel Sambuc
199*11be35a1SLionel Sambuc if (atf_is_error(err))
200*11be35a1SLionel Sambuc atf_map_fini(m);
201*11be35a1SLionel Sambuc
202*11be35a1SLionel Sambuc return err;
203*11be35a1SLionel Sambuc }
204*11be35a1SLionel Sambuc
205*11be35a1SLionel Sambuc void
atf_map_fini(atf_map_t * m)206*11be35a1SLionel Sambuc atf_map_fini(atf_map_t *m)
207*11be35a1SLionel Sambuc {
208*11be35a1SLionel Sambuc atf_list_iter_t iter;
209*11be35a1SLionel Sambuc
210*11be35a1SLionel Sambuc atf_list_for_each(iter, &m->m_list) {
211*11be35a1SLionel Sambuc struct map_entry *me = atf_list_iter_data(iter);
212*11be35a1SLionel Sambuc
213*11be35a1SLionel Sambuc if (me->m_managed)
214*11be35a1SLionel Sambuc free(me->m_value);
215*11be35a1SLionel Sambuc free(me->m_key);
216*11be35a1SLionel Sambuc free(me);
217*11be35a1SLionel Sambuc }
218*11be35a1SLionel Sambuc atf_list_fini(&m->m_list);
219*11be35a1SLionel Sambuc }
220*11be35a1SLionel Sambuc
221*11be35a1SLionel Sambuc /*
222*11be35a1SLionel Sambuc * Getters.
223*11be35a1SLionel Sambuc */
224*11be35a1SLionel Sambuc
225*11be35a1SLionel Sambuc atf_map_iter_t
atf_map_begin(atf_map_t * m)226*11be35a1SLionel Sambuc atf_map_begin(atf_map_t *m)
227*11be35a1SLionel Sambuc {
228*11be35a1SLionel Sambuc atf_map_iter_t iter;
229*11be35a1SLionel Sambuc iter.m_map = m;
230*11be35a1SLionel Sambuc iter.m_listiter = atf_list_begin(&m->m_list);
231*11be35a1SLionel Sambuc iter.m_entry = atf_list_iter_data(iter.m_listiter);
232*11be35a1SLionel Sambuc return iter;
233*11be35a1SLionel Sambuc }
234*11be35a1SLionel Sambuc
235*11be35a1SLionel Sambuc atf_map_citer_t
atf_map_begin_c(const atf_map_t * m)236*11be35a1SLionel Sambuc atf_map_begin_c(const atf_map_t *m)
237*11be35a1SLionel Sambuc {
238*11be35a1SLionel Sambuc atf_map_citer_t citer;
239*11be35a1SLionel Sambuc citer.m_map = m;
240*11be35a1SLionel Sambuc citer.m_listiter = atf_list_begin_c(&m->m_list);
241*11be35a1SLionel Sambuc citer.m_entry = atf_list_citer_data(citer.m_listiter);
242*11be35a1SLionel Sambuc return citer;
243*11be35a1SLionel Sambuc }
244*11be35a1SLionel Sambuc
245*11be35a1SLionel Sambuc atf_map_iter_t
atf_map_end(atf_map_t * m)246*11be35a1SLionel Sambuc atf_map_end(atf_map_t *m)
247*11be35a1SLionel Sambuc {
248*11be35a1SLionel Sambuc atf_map_iter_t iter;
249*11be35a1SLionel Sambuc iter.m_map = m;
250*11be35a1SLionel Sambuc iter.m_entry = NULL;
251*11be35a1SLionel Sambuc iter.m_listiter = atf_list_end(&m->m_list);
252*11be35a1SLionel Sambuc return iter;
253*11be35a1SLionel Sambuc }
254*11be35a1SLionel Sambuc
255*11be35a1SLionel Sambuc atf_map_citer_t
atf_map_end_c(const atf_map_t * m)256*11be35a1SLionel Sambuc atf_map_end_c(const atf_map_t *m)
257*11be35a1SLionel Sambuc {
258*11be35a1SLionel Sambuc atf_map_citer_t iter;
259*11be35a1SLionel Sambuc iter.m_map = m;
260*11be35a1SLionel Sambuc iter.m_entry = NULL;
261*11be35a1SLionel Sambuc iter.m_listiter = atf_list_end_c(&m->m_list);
262*11be35a1SLionel Sambuc return iter;
263*11be35a1SLionel Sambuc }
264*11be35a1SLionel Sambuc
265*11be35a1SLionel Sambuc atf_map_iter_t
atf_map_find(atf_map_t * m,const char * key)266*11be35a1SLionel Sambuc atf_map_find(atf_map_t *m, const char *key)
267*11be35a1SLionel Sambuc {
268*11be35a1SLionel Sambuc atf_list_iter_t iter;
269*11be35a1SLionel Sambuc
270*11be35a1SLionel Sambuc atf_list_for_each(iter, &m->m_list) {
271*11be35a1SLionel Sambuc struct map_entry *me = atf_list_iter_data(iter);
272*11be35a1SLionel Sambuc
273*11be35a1SLionel Sambuc if (strcmp(me->m_key, key) == 0) {
274*11be35a1SLionel Sambuc atf_map_iter_t i;
275*11be35a1SLionel Sambuc i.m_map = m;
276*11be35a1SLionel Sambuc i.m_entry = me;
277*11be35a1SLionel Sambuc i.m_listiter = iter;
278*11be35a1SLionel Sambuc return i;
279*11be35a1SLionel Sambuc }
280*11be35a1SLionel Sambuc }
281*11be35a1SLionel Sambuc
282*11be35a1SLionel Sambuc return atf_map_end(m);
283*11be35a1SLionel Sambuc }
284*11be35a1SLionel Sambuc
285*11be35a1SLionel Sambuc atf_map_citer_t
atf_map_find_c(const atf_map_t * m,const char * key)286*11be35a1SLionel Sambuc atf_map_find_c(const atf_map_t *m, const char *key)
287*11be35a1SLionel Sambuc {
288*11be35a1SLionel Sambuc atf_list_citer_t iter;
289*11be35a1SLionel Sambuc
290*11be35a1SLionel Sambuc atf_list_for_each_c(iter, &m->m_list) {
291*11be35a1SLionel Sambuc const struct map_entry *me = atf_list_citer_data(iter);
292*11be35a1SLionel Sambuc
293*11be35a1SLionel Sambuc if (strcmp(me->m_key, key) == 0) {
294*11be35a1SLionel Sambuc atf_map_citer_t i;
295*11be35a1SLionel Sambuc i.m_map = m;
296*11be35a1SLionel Sambuc i.m_entry = me;
297*11be35a1SLionel Sambuc i.m_listiter = iter;
298*11be35a1SLionel Sambuc return i;
299*11be35a1SLionel Sambuc }
300*11be35a1SLionel Sambuc }
301*11be35a1SLionel Sambuc
302*11be35a1SLionel Sambuc return atf_map_end_c(m);
303*11be35a1SLionel Sambuc }
304*11be35a1SLionel Sambuc
305*11be35a1SLionel Sambuc size_t
atf_map_size(const atf_map_t * m)306*11be35a1SLionel Sambuc atf_map_size(const atf_map_t *m)
307*11be35a1SLionel Sambuc {
308*11be35a1SLionel Sambuc return atf_list_size(&m->m_list);
309*11be35a1SLionel Sambuc }
310*11be35a1SLionel Sambuc
311*11be35a1SLionel Sambuc char **
atf_map_to_charpp(const atf_map_t * l)312*11be35a1SLionel Sambuc atf_map_to_charpp(const atf_map_t *l)
313*11be35a1SLionel Sambuc {
314*11be35a1SLionel Sambuc char **array;
315*11be35a1SLionel Sambuc atf_map_citer_t iter;
316*11be35a1SLionel Sambuc size_t i;
317*11be35a1SLionel Sambuc
318*11be35a1SLionel Sambuc array = malloc(sizeof(char *) * (atf_map_size(l) * 2 + 1));
319*11be35a1SLionel Sambuc if (array == NULL)
320*11be35a1SLionel Sambuc goto out;
321*11be35a1SLionel Sambuc
322*11be35a1SLionel Sambuc i = 0;
323*11be35a1SLionel Sambuc atf_map_for_each_c(iter, l) {
324*11be35a1SLionel Sambuc array[i] = strdup(atf_map_citer_key(iter));
325*11be35a1SLionel Sambuc if (array[i] == NULL) {
326*11be35a1SLionel Sambuc atf_utils_free_charpp(array);
327*11be35a1SLionel Sambuc array = NULL;
328*11be35a1SLionel Sambuc goto out;
329*11be35a1SLionel Sambuc }
330*11be35a1SLionel Sambuc
331*11be35a1SLionel Sambuc array[i + 1] = strdup((const char *)atf_map_citer_data(iter));
332*11be35a1SLionel Sambuc if (array[i + 1] == NULL) {
333*11be35a1SLionel Sambuc atf_utils_free_charpp(array);
334*11be35a1SLionel Sambuc array = NULL;
335*11be35a1SLionel Sambuc goto out;
336*11be35a1SLionel Sambuc }
337*11be35a1SLionel Sambuc
338*11be35a1SLionel Sambuc i += 2;
339*11be35a1SLionel Sambuc }
340*11be35a1SLionel Sambuc array[i] = NULL;
341*11be35a1SLionel Sambuc
342*11be35a1SLionel Sambuc out:
343*11be35a1SLionel Sambuc return array;
344*11be35a1SLionel Sambuc }
345*11be35a1SLionel Sambuc
346*11be35a1SLionel Sambuc /*
347*11be35a1SLionel Sambuc * Modifiers.
348*11be35a1SLionel Sambuc */
349*11be35a1SLionel Sambuc
350*11be35a1SLionel Sambuc atf_error_t
atf_map_insert(atf_map_t * m,const char * key,void * value,bool managed)351*11be35a1SLionel Sambuc atf_map_insert(atf_map_t *m, const char *key, void *value, bool managed)
352*11be35a1SLionel Sambuc {
353*11be35a1SLionel Sambuc struct map_entry *me;
354*11be35a1SLionel Sambuc atf_error_t err;
355*11be35a1SLionel Sambuc atf_map_iter_t iter;
356*11be35a1SLionel Sambuc
357*11be35a1SLionel Sambuc iter = atf_map_find(m, key);
358*11be35a1SLionel Sambuc if (atf_equal_map_iter_map_iter(iter, atf_map_end(m))) {
359*11be35a1SLionel Sambuc me = new_entry(key, value, managed);
360*11be35a1SLionel Sambuc if (me == NULL)
361*11be35a1SLionel Sambuc err = atf_no_memory_error();
362*11be35a1SLionel Sambuc else {
363*11be35a1SLionel Sambuc err = atf_list_append(&m->m_list, me, false);
364*11be35a1SLionel Sambuc if (atf_is_error(err)) {
365*11be35a1SLionel Sambuc if (managed)
366*11be35a1SLionel Sambuc free(value);
367*11be35a1SLionel Sambuc free(me);
368*11be35a1SLionel Sambuc }
369*11be35a1SLionel Sambuc }
370*11be35a1SLionel Sambuc } else {
371*11be35a1SLionel Sambuc me = iter.m_entry;
372*11be35a1SLionel Sambuc if (me->m_managed)
373*11be35a1SLionel Sambuc free(me->m_value);
374*11be35a1SLionel Sambuc
375*11be35a1SLionel Sambuc INV(strcmp(me->m_key, key) == 0);
376*11be35a1SLionel Sambuc me->m_value = value;
377*11be35a1SLionel Sambuc me->m_managed = managed;
378*11be35a1SLionel Sambuc
379*11be35a1SLionel Sambuc err = atf_no_error();
380*11be35a1SLionel Sambuc }
381*11be35a1SLionel Sambuc
382*11be35a1SLionel Sambuc return err;
383*11be35a1SLionel Sambuc }
384