summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-09-07 15:22:52 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-09-07 15:22:52 +0100
commit6c2d97bf01c25f2af6fd41a741ca0f74230fd8f5 (patch)
treeed06643d678033a8e7dee5acb6267755a8e2b2ce /utils
parent2d87e7ebeacb33836f8c959a00bb059ff3683963 (diff)
downloadnetsurf-6c2d97bf01c25f2af6fd41a741ca0f74230fd8f5.tar.gz
netsurf-6c2d97bf01c25f2af6fd41a741ca0f74230fd8f5.tar.bz2
useragent: Add a free_user_agent_string() function
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'utils')
-rw-r--r--utils/useragent.c10
-rw-r--r--utils/useragent.h7
2 files changed, 17 insertions, 0 deletions
diff --git a/utils/useragent.c b/utils/useragent.c
index b528dce4f..3d93a97b2 100644
--- a/utils/useragent.c
+++ b/utils/useragent.c
@@ -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;
+ }
+}
diff --git a/utils/useragent.h b/utils/useragent.h
index 87677e7bc..6eb309a62 100644
--- a/utils/useragent.h
+++ b/utils/useragent.h
@@ -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