]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Rename cursor free functions to make it clearer what they do
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 Jan 2018 03:11:29 +0000 (20:11 -0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 25 Jan 2018 19:12:23 +0000 (12:12 -0700)
src/include/cursor.h
src/lib/util/cursor.c
src/main/map.c
src/main/xlat_eval.c
src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c

index bcf660d5d396c0da9e39be4cd346e30936c3d344..b39ba175cfdc0afbf65480b338765f8734e8763b 100644 (file)
@@ -81,7 +81,7 @@ void *fr_cursor_remove(fr_cursor_t *cursor) CC_HINT(nonnull);
 
 void *fr_cursor_replace(fr_cursor_t *cursor, void *r) CC_HINT(nonnull);
 
-void fr_cursor_list_free(fr_cursor_t *cursor) CC_HINT(nonnull);
+void fr_cursor_free_list(fr_cursor_t *cursor) CC_HINT(nonnull);
 
 /** Initialise a cursor with runtime talloc type safety checks and a custom iterator
  *
@@ -138,14 +138,14 @@ void fr_cursor_list_free(fr_cursor_t *cursor) CC_HINT(nonnull);
 void *_fr_cursor_init(fr_cursor_t *cursor, void * const *head, size_t offset,
                      fr_cursor_iter_t iter, void const *ctx, char const *type);
 
-/** talloc_free the current item, and all subsequent items
+/** talloc_free the current item
  *
  * @param[in] cursor   to free items from.
  */
-static inline void fr_cursor_free(fr_cursor_t *cursor)
+static inline void fr_cursor_free_item(fr_cursor_t *cursor)
 {
-       void *v;
        if (!cursor) return;
-       while ((v = fr_cursor_remove(cursor))) talloc_free(v);
+
+       talloc_free(fr_cursor_remove(cursor));
 }
 #endif
index 278a16ea28df4dead290e16bc73688340c77896a..3fdd08f5e319dbdce93f40005dbb1df50e8488ba 100644 (file)
@@ -521,11 +521,11 @@ void * CC_HINT(hot) fr_cursor_replace(fr_cursor_t *cursor, void *r)
  *
  * @param[in] cursor to free items in.
  */
-void fr_cursor_list_free(fr_cursor_t *cursor)
+void fr_cursor_free_list(fr_cursor_t *cursor)
 {
        void *v;
 
-       if (!*cursor->head) return;     /* noop */
+       if (!*(cursor->head)) return;   /* noop */
 
        do {
                v = fr_cursor_remove(cursor);
@@ -1670,7 +1670,7 @@ void test_cursor_free(void)
        fr_cursor_append(&cursor, item3);
 
        fr_cursor_next(&cursor);
-       fr_cursor_list_free(&cursor);
+       fr_cursor_free_list(&cursor);
 
        TEST_CHECK(fr_cursor_current(&cursor) == NULL);
        TEST_CHECK(!fr_cursor_list_prev_peek(&cursor));
index 5e565d47a32dc1ad8d366204b735c896cb6b4f11..3166838f5c5aa6feb2e24a8df06cc8d44d2b081e 100644 (file)
@@ -937,10 +937,10 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                                if (!n_vb) {
                                xlat_error:
                                        fr_cursor_head(&from);
-                                       fr_cursor_free(&from);
+                                       fr_cursor_free_list(&from);
 
                                        fr_cursor_head(&values);
-                                       fr_cursor_free(&values);
+                                       fr_cursor_free_list(&values);
                                        goto error;
                                }
 
@@ -1005,7 +1005,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                        if (!n_vb) {
                        attr_error:
                                fr_cursor_head(&values);
-                               fr_cursor_free(&values);
+                               fr_cursor_free_list(&values);
                                goto error;
                        }
 
@@ -1045,7 +1045,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out,
                        if (!n_vb) {
                        data_error:
                                fr_cursor_head(&values);
-                               fr_cursor_free(&values);
+                               fr_cursor_free_list(&values);
                                goto error;
                        }
                        /*
@@ -1201,7 +1201,7 @@ static VALUE_PAIR *map_list_mod_to_vps(TALLOC_CTX *ctx, vp_list_mod_t const *vlm
                        vp = map_list_mod_to_vp(ctx, mod->lhs, vb);
                        if (!vp) {
                                fr_cursor_head(&cursor);
-                               fr_cursor_free(&cursor);
+                               fr_cursor_free_list(&cursor);
                                return NULL;
                        }
                        fr_cursor_insert(&cursor, vp);
index 4ce56650a02e56b96e9dd2d633d44ae677c4675a..3dcf84169e9ac763f47b05cd324f60ee9699e408 100644 (file)
@@ -741,7 +741,7 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_cursor_t *out, xlat_exp_t cons
                                   node->fmt);
                        if (xlat_eval_one_letter(ctx, out, request, node->fmt[0]) == XLAT_ACTION_FAIL) {
                        fail:
-                               fr_cursor_free(out);    /* Only frees what we've added during this call */
+                               fr_cursor_free_list(out);       /* Only frees what we've added during this call */
                                xa = XLAT_ACTION_FAIL;
                                goto finish;
                        }
@@ -884,11 +884,11 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
                 */
                if (fr_value_box_cast(ctx, &string, FR_TYPE_STRING, NULL, head) < 0) {
                        RPERROR("Casting one letter expansion to string failed");
-                       fr_cursor_free(&cursor);
+                       fr_cursor_free_list(&cursor);
                        return NULL;
                }
                memcpy(&str, &string.vb_strvalue, sizeof(str));
-               fr_cursor_free(&cursor);
+               fr_cursor_free_list(&cursor);
                break;
 
        case XLAT_ATTRIBUTE:
@@ -907,7 +907,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
                if (!str) {
                attr_error:
                        RPERROR("Printing box to string failed");
-                       fr_cursor_free(&cursor);
+                       fr_cursor_free_list(&cursor);
                        return NULL;
                }
 
@@ -925,7 +925,7 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
                        str = talloc_strdup_append_buffer(str, more);
                        talloc_free(more);
                }
-               fr_cursor_free(&cursor);
+               fr_cursor_free_list(&cursor);
                break;
 
        case XLAT_VIRTUAL:
index 5feff3c1b8638429507b900485d75641ba0ec575..c8c1a9b6bdfe76e738db47cb7505e47888ab8d03 100644 (file)
@@ -158,7 +158,7 @@ static ssize_t eap_ttls_decode_pair(TALLOC_CTX *ctx, fr_cursor_t *cursor, fr_dic
                if ((end - p) < 8) {
                        fr_strerror_printf("Malformed diameter VPs.  Needed at least 8 bytes, got %zu bytes", end - p);
                error:
-                       fr_cursor_list_free(cursor);
+                       fr_cursor_free_list(cursor);
                        return -1;
                }