diff options
Diffstat (limited to 'epan/wmem/wmem_interval_tree.h')
-rw-r--r-- | epan/wmem/wmem_interval_tree.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/epan/wmem/wmem_interval_tree.h b/epan/wmem/wmem_interval_tree.h index cf418cad9d..c4f903b126 100644 --- a/epan/wmem/wmem_interval_tree.h +++ b/epan/wmem/wmem_interval_tree.h @@ -54,6 +54,15 @@ struct _wmem_range_t { guint64 max_edge; /* max value among subtrees */ }; +/** + * Callback to provide the data for an interval. The original data that is + * replaced by the new data are passed as "oldData1" and "oldData2". If there + * was no previous interval, then these will be NULL. It is the responsibility + * of this callback to deallocate resources associated with the old data. + */ +typedef void *(*wmem_itree_data_callback)(void *oldData1, void *oldData2); + + WS_DLL_PUBLIC wmem_itree_t * wmem_itree_new(wmem_allocator_t *allocator) @@ -74,6 +83,16 @@ WS_DLL_PUBLIC void wmem_itree_insert(wmem_itree_t *tree, const guint64 low, const guint64 high, void *data); +/** Inserts a point indexed by "pos" in O(log(n)). + * + * Pre-condition: there must not be overlapping or directly adjacent intervals + * (guaranteed by using only wmem_itree_insert_point). + * If the point already exists, nothing is done. Otherwise an interval is + * created or updated, invoking the callback to obtain the new data. + */ +WS_DLL_PUBLIC +void +wmem_itree_insert_point(wmem_itree_t *tree, const guint64 pos, wmem_itree_data_callback callback); /* * Save results in a wmem_list with the scope passed as a parameter. |