diff options
Diffstat (limited to 'epan')
-rw-r--r-- | epan/uat-int.h | 6 | ||||
-rw-r--r-- | epan/uat.c | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/epan/uat-int.h b/epan/uat-int.h index c36a5c136e..a272c8f209 100644 --- a/epan/uat-int.h +++ b/epan/uat-int.h @@ -112,6 +112,12 @@ WS_DLL_PUBLIC void uat_remove_record_idx(uat_t *uat, guint rec_idx); /** + * Moves the entry from the old position to the new one + */ +WS_DLL_PUBLIC +void uat_move_index(uat_t *uat, guint old_idx, guint new_idx); + +/** * Removes and destroys all records from the UAT. */ WS_DLL_PUBLIC diff --git a/epan/uat.c b/epan/uat.c index 71403485b7..03f73d2a34 100644 --- a/epan/uat.c +++ b/epan/uat.c @@ -225,6 +225,20 @@ void uat_remove_record_idx(uat_t* uat, guint idx) { g_array_remove_index(uat->valid_data, idx); } +void uat_move_index(uat_t * uat, guint old_idx, guint new_idx) +{ + guint dir = 1; + guint start = old_idx; + if ( old_idx > new_idx ) + dir = -1; + + while ( start != new_idx ) + { + uat_swap(uat, start, start + dir); + start += dir; + } +} + /* The returned filename was g_malloc()'d so the caller must free it */ gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing) { gchar *pers_fname = NULL; |