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:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user