diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/wee-hdata.c | 27 | ||||
-rw-r--r-- | src/core/wee-hdata.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c index 5222af69e..2204af014 100644 --- a/src/core/wee-hdata.c +++ b/src/core/wee-hdata.c @@ -236,6 +236,33 @@ hdata_get_list (struct t_hdata *hdata, const char *name) } /* + * hdata_check_pointer: check if a pointer is valid for a given hdata/list + * return 1 if pointer exists in list + * 0 if pointer does not exist + */ + +int +hdata_check_pointer (struct t_hdata *hdata, void *list, void *pointer) +{ + void *ptr_current; + + if (hdata && list && pointer) + { + if (pointer == list) + return 1; + ptr_current = list; + while (ptr_current) + { + ptr_current = hdata_move (hdata, ptr_current, 1); + if (ptr_current && (ptr_current == pointer)) + return 1; + } + } + + return 0; +} + +/* * hdata_move: move pointer to another element in list */ diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h index a55e522eb..66d82202b 100644 --- a/src/core/wee-hdata.h +++ b/src/core/wee-hdata.h @@ -61,6 +61,8 @@ extern void *hdata_get_var (struct t_hdata *hdata, void *pointer, extern void *hdata_get_var_at_offset (struct t_hdata *hdata, void *pointer, int offset); extern void *hdata_get_list (struct t_hdata *hdata, const char *name); +extern int hdata_check_pointer (struct t_hdata *hdata, void *list, + void *pointer); extern void *hdata_move (struct t_hdata *hdata, void *pointer, int count); extern char hdata_char (struct t_hdata *hdata, void *pointer, const char *name); |