summaryrefslogtreecommitdiff
path: root/lib/fstrcmp.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-02-16 13:49:49 +0100
committerBruno Haible <bruno@clisp.org>2020-02-16 13:49:49 +0100
commitb5ba60c50b5c0e510e06d5f8137a922ba4895b17 (patch)
tree1e6c4d049b6b072ef8f9b39341f7955f7f99c709 /lib/fstrcmp.c
parent03d7a6b1fa91b8a22b3b335ee8e70536e4dd65e4 (diff)
downloadgnulib-b5ba60c50b5c0e510e06d5f8137a922ba4895b17.tar.gz
fstrcmp: Add API to clean up resources.
Reported by Akim Demaille <akim@lrde.epita.fr> in <https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00080.html>. * lib/fstrcmp.h (fstrcmp_free_resources): New declaration. * lib/fstrcmp.c (fstrcmp_free_resources): New function.
Diffstat (limited to 'lib/fstrcmp.c')
-rw-r--r--lib/fstrcmp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/fstrcmp.c b/lib/fstrcmp.c
index c6a66389e3..1a4fbfdf8d 100644
--- a/lib/fstrcmp.c
+++ b/lib/fstrcmp.c
@@ -73,6 +73,21 @@ keys_init (void)
/* Ensure that keys_init is called once only. */
gl_once_define(static, keys_init_once)
+void
+fstrcmp_free_resources (void)
+{
+ ptrdiff_t *buffer;
+
+ gl_once (keys_init_once, keys_init);
+ buffer = gl_tls_get (buffer_key);
+ if (buffer != NULL)
+ {
+ gl_tls_set (buffer_key, NULL);
+ gl_tls_set (bufmax_key, (void *) (uintptr_t) 0);
+ free (buffer);
+ }
+}
+
/* In the code below, branch probabilities were measured by Ralf Wildenhues,
by running "msgmerge LL.po coreutils.pot" with msgmerge 0.18 for many