MINOR: tools: ha_freearray() frees an array of string
ha_freearray() is a new function which free() an array of strings terminated by a NULL entry. The pointer to the array will be free and set to NULL.
This commit is contained in:
parent
311e0aa5c7
commit
96b1f1fd26
@ -1390,4 +1390,6 @@ static inline const char *errname(int err_num, char **out)
|
||||
|
||||
int path_base(const char *path, const char *base, char *dst, char **err);
|
||||
|
||||
void ha_freearray(char ***array);
|
||||
|
||||
#endif /* _HAPROXY_TOOLS_H */
|
||||
|
16
src/tools.c
16
src/tools.c
@ -7318,6 +7318,22 @@ out:
|
||||
return err_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* free() an array of strings terminated by a NULL entry
|
||||
* set the pointer to NULL
|
||||
*/
|
||||
void ha_freearray(char ***array)
|
||||
{
|
||||
int i;
|
||||
char **r = *array;
|
||||
|
||||
for (i = 0; r && r[i]; i++) {
|
||||
free(r[i]);
|
||||
r[i] = NULL;
|
||||
}
|
||||
*array = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user