@@ -122,6 +122,47 @@ static void state_constraint_destructor (void **item)
122122 }
123123}
124124
125+ /* zlistx_set_destructor */
126+ static void wrap_free (void * * item )
127+ {
128+ if (item ) {
129+ free (* item );
130+ (* item ) = NULL ;
131+ }
132+ }
133+
134+ static state_match_t match_states (struct state_constraint * c ,
135+ flux_job_state_t state )
136+ {
137+ int * states = zlistx_first (c -> values );
138+ if ((* states ) & state )
139+ return MATCH_ALWAYS ;
140+ return MATCH_NEVER ;
141+ }
142+
143+ static struct state_constraint * create_states_constraint (json_t * values ,
144+ flux_error_t * errp )
145+ {
146+ struct state_constraint * c ;
147+ int * bitmask = NULL ;
148+ int tmp ;
149+ if ((tmp = array_to_states_bitmask (values , errp )) < 0 )
150+ return NULL ;
151+ /* if no states specified, returns MATCH_ALWAYS */
152+ if (!tmp )
153+ return state_constraint_new (match_always , NULL , errp );
154+ if (!(bitmask = malloc (sizeof (* bitmask ))))
155+ return NULL ;
156+ (* bitmask ) = tmp ;
157+ if (!(c = state_constraint_new (match_states , wrap_free , errp ))
158+ || !zlistx_add_end (c -> values , bitmask )) {
159+ state_constraint_destroy (c );
160+ free (bitmask );
161+ return NULL ;
162+ }
163+ return c ;
164+ }
165+
125166static state_match_t match_and (struct state_constraint * c ,
126167 flux_job_state_t state )
127168{
@@ -237,47 +278,6 @@ static struct state_constraint *conditional_constraint (const char *type,
237278 return NULL ;
238279}
239280
240- /* zlistx_set_destructor */
241- static void wrap_free (void * * item )
242- {
243- if (item ) {
244- free (* item );
245- (* item ) = NULL ;
246- }
247- }
248-
249- static state_match_t match_states (struct state_constraint * c ,
250- flux_job_state_t state )
251- {
252- int * states = zlistx_first (c -> values );
253- if ((* states ) & state )
254- return MATCH_ALWAYS ;
255- return MATCH_NEVER ;
256- }
257-
258- static struct state_constraint * create_states_constraint (json_t * values ,
259- flux_error_t * errp )
260- {
261- struct state_constraint * c ;
262- int * bitmask = NULL ;
263- int tmp ;
264- if ((tmp = array_to_states_bitmask (values , errp )) < 0 )
265- return NULL ;
266- /* if no states specified, returns MATCH_ALWAYS */
267- if (!tmp )
268- return state_constraint_new (match_always , NULL , errp );
269- if (!(bitmask = malloc (sizeof (* bitmask ))))
270- return NULL ;
271- (* bitmask ) = tmp ;
272- if (!(c = state_constraint_new (match_states , wrap_free , errp ))
273- || !zlistx_add_end (c -> values , bitmask )) {
274- state_constraint_destroy (c );
275- free (bitmask );
276- return NULL ;
277- }
278- return c ;
279- }
280-
281281void state_constraint_destroy (struct state_constraint * constraint )
282282{
283283 if (constraint ) {
0 commit comments