+2020-02-16 Bruno Haible <bruno@clisp.org>
+
+ 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.
+
2020-02-14 Bruno Haible <bruno@clisp.org>
wctype-h: Fix compilation errors in C++ (regression from 2020-01-25).
/* 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
/* A shortcut for fstrcmp. Avoids a function call. */
#define fstrcmp(s1,s2) fstrcmp_bounded (s1, s2, 0.0)
+/* Frees the per-thread resources allocated by this module for the current
+ thread.
+ You don't need to call this function in threads other than the main thread,
+ because per-thread resources are reclaimed automatically when the thread
+ exits. However, per-thread resources allocated by the main thread are
+ comparable to static allocations; calling this function can be useful to
+ avoid an error report from valgrind. */
+extern void fstrcmp_free_resources (void);
+
#ifdef __cplusplus
}
#endif