1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 16:23:14 +02:00

api: add new function hdata_check_pointer

This commit is contained in:
Sebastien Helleu
2011-12-17 17:03:39 +01:00
parent dc8807a417
commit bd3f554e02
19 changed files with 503 additions and 82 deletions
+27
View File
@@ -235,6 +235,33 @@ hdata_get_list (struct t_hdata *hdata, const char *name)
return NULL;
}
/*
* 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
*/
+2
View File
@@ -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);