diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-12-17 17:03:39 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-12-17 17:03:39 +0100 |
commit | bd3f554e0228e5aec087b07a269596b487f3a60f (patch) | |
tree | 4861f8e07c16073791a44033450e729b62b64679 /src/core/wee-hdata.c | |
parent | dc8807a4173ccabbe3bb03d3f1d02c8b11580056 (diff) | |
download | weechat-bd3f554e0228e5aec087b07a269596b487f3a60f.zip |
api: add new function hdata_check_pointer
Diffstat (limited to 'src/core/wee-hdata.c')
-rw-r--r-- | src/core/wee-hdata.c | 27 |
1 files changed, 27 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 */ |