useragent: Add a free_user_agent_string() function

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2019-09-07 15:22:52 +01:00
parent 2d87e7ebea
commit 6c2d97bf01
2 changed files with 17 additions and 0 deletions

View File

@ -78,3 +78,13 @@ user_agent_string(void)
return core_user_agent_string;
}
/* Public API documented in useragent.h */
void
free_user_agent_string(void)
{
if (core_user_agent_string != NULL) {
/* Nasty cast because we need to de-const it to free it */
free((void *)core_user_agent_string);
core_user_agent_string = NULL;
}
}

View File

@ -27,4 +27,11 @@
*/
const char * user_agent_string(void);
/** Free any memory allocated for the user_agent_string
*
* After calling this, the value returned by \ref user_agent_string()
* is to be considered invalid.
*/
void free_user_agent_string(void);
#endif