aboutsummaryrefslogtreecommitdiffstats
path: root/epan/range.h
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-12-22 15:12:27 -0500
committerMichael Mann <mmann78@netscape.net>2017-01-07 00:44:10 +0000
commit6a6d7ea34f43515dfe3f52aa96b943c272c925a7 (patch)
treedbf89a2226861fa855cc04d80607c56f7268e51b /epan/range.h
parent29a7fce2720288c86e474f68880a0e61e517027b (diff)
Convert range API to always use wmem memory.
This is mostly to address memory leaks in range preferences (the biggest user of range functionality) on shutdown. Now range preferences must use epan scoped memory when referencing internal preference structures to keep consistency. Change-Id: Idc644f59b5b42fa1d46891542b53ff13ea754157 Reviewed-on: https://code.wireshark.org/review/19387 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/range.h')
-rw-r--r--epan/range.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/epan/range.h b/epan/range.h
index b59119e3ae..c37586bd6e 100644
--- a/epan/range.h
+++ b/epan/range.h
@@ -64,7 +64,7 @@ typedef enum {
CVT_NUMBER_TOO_BIG
} convert_ret_t;
-WS_DLL_PUBLIC range_t *range_empty(void);
+WS_DLL_PUBLIC range_t *range_empty(wmem_allocator_t *scope);
/*** Converts a range string to a fast comparable array of ranges.
@@ -84,15 +84,16 @@ WS_DLL_PUBLIC range_t *range_empty(void);
* 20,30,40- 20, 30, and the range from 40 to the end
* 20-10,30-25 Range from 10 to 20, and from 25 to 30
* - All values
+ * @param scope memory scope for the range
* @param range the range
* @param es points to the string to be converted.
* @param max_value specifies the maximum value in a range.
* @return convert_ret_t
*/
-WS_DLL_PUBLIC convert_ret_t range_convert_str(range_t **range, const gchar *es,
+WS_DLL_PUBLIC convert_ret_t range_convert_str(wmem_allocator_t *scope, range_t **range, const gchar *es,
guint32 max_value);
-WS_DLL_PUBLIC convert_ret_t range_convert_str_work(range_t **range, const gchar *es,
+WS_DLL_PUBLIC convert_ret_t range_convert_str_work(wmem_allocator_t *scope, range_t **range, const gchar *es,
guint32 max_value, gboolean err_on_max);
/** This function returns TRUE if a given value is within one of the ranges
@@ -105,19 +106,21 @@ WS_DLL_PUBLIC gboolean value_is_in_range(range_t *range, guint32 val);
/** This function returns TRUE if val has successfully been added to
* a range. This may extend an existing range or create a new one
+ * @param scope memory scope of range (in case of reallocation)
* @param range to add value
* @param val value to add to range
* @return TRUE if the value is successsfully added to range
*/
-WS_DLL_PUBLIC gboolean range_add_value(range_t **range, guint32 val);
+WS_DLL_PUBLIC gboolean range_add_value(wmem_allocator_t *scope, range_t **range, guint32 val);
/** This function returns TRUE if val has successfully been removed from
* a range. This may remove an existing range.
+ * @param scope memory scope of range (in case of reallocation)
* @param range to remove value
* @param val value to remove within range
* @return TRUE if the value is successsfully removed to range
*/
-WS_DLL_PUBLIC gboolean range_remove_value(range_t **range, guint32 val);
+WS_DLL_PUBLIC gboolean range_remove_value(wmem_allocator_t *scope, range_t **range, guint32 val);
/** This function returns TRUE if the two given range_t's are equal.
* @param a first range
@@ -139,11 +142,12 @@ WS_DLL_PUBLIC void range_foreach(range_t *range, void (*callback)(guint32 val));
WS_DLL_PUBLIC char *range_convert_range(wmem_allocator_t *scope, const range_t *range);
/**
- * Create a copy of a range.
+ * Create a (wmem-alloc()ed) copy of a range
+ * @param scope memory scope for the copied range
* @param src the range to copy
* @return ep allocated copy of the range
*/
-WS_DLL_PUBLIC range_t *range_copy(range_t *src);
+WS_DLL_PUBLIC range_t *range_copy(wmem_allocator_t *scope, range_t *src);
#ifdef __cplusplus
}