]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Amend fr_proto_next_encodable() to work with fr_dcursor_t
authorNick Porter <nick@portercomputing.co.uk>
Tue, 22 Dec 2020 18:05:12 +0000 (18:05 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 21 Jan 2021 23:05:49 +0000 (23:05 +0000)
src/lib/util/proto.c
src/lib/util/proto.h

index 57b0f8534548f8816316593efeedaa4210892a93..772968fc3963b2ec489f3062e2c092a074a54535 100644 (file)
@@ -89,9 +89,7 @@ void fr_proto_da_stack_print(char const *file, int line, char const *func, fr_da
 
 /** Implements the default iterator to encode pairs belonging to a specific dictionary that are not internal
  *
- * @param[in,out] prev The fr_pair_t before curr. Will be updated to point to the
- *                     pair before the one returned, or the last pair in the list
- *                     if no matching pairs found.
+ * @param[in] list     to itterate over.
  * @param[in] to_eval  The fr_pair_t after cursor->current.  Will be checked to
  *                     see if it matches the specified fr_dict_t.
  * @param[in] uctx     The fr_dict_t to search for.
@@ -99,20 +97,18 @@ void fr_proto_da_stack_print(char const *file, int line, char const *func, fr_da
  *     - Next matching fr_pair_t.
  *     - NULL if not more matching fr_pair_ts could be found.
  */
-void *fr_proto_next_encodable(void **prev, void *to_eval, void *uctx)
+void *fr_proto_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx)
 {
-       fr_pair_t       *c, *p;
+       fr_pair_t       *c;
        fr_dict_t       *dict = talloc_get_type_abort(uctx, fr_dict_t);
 
        if (!to_eval) return NULL;
 
-       for (p = *prev, c = to_eval; c; p = c, c = c->next) {
+       for (c = to_eval; c; c = fr_dlist_next(list, c)) {
                VP_VERIFY(c);
                if ((c->da->dict == dict) && (!c->da->flags.internal)) break;
        }
 
-       *prev = p;
-
        return c;
 }
 
index f622e67f037b3880468da78a1b2aef6275d9db8e..531a2bf51b438889261583452fca19a5f34d17dd 100644 (file)
@@ -62,7 +62,7 @@ void fr_proto_print_hex_data(char const *file, int line, uint8_t const *data, si
 
 void fr_proto_print_hex_marker(char const *file, int line, uint8_t const *data, size_t data_len, ssize_t slen, char const *fmt, ...);
 
-void *fr_proto_next_encodable(void **prev, void *to_eval, void *uctx);
+void *fr_proto_next_encodable(fr_dlist_head_t *list, void *to_eval, void *uctx);
 
 void fr_proto_da_stack_print(char const *file, int line, char const *func, fr_da_stack_t *da_stack, unsigned int depth);