Add XFreeThreads function.

This commit is contained in:
Oliver 2022-11-11 17:04:00 +00:00 committed by Alan Coopersmith
parent b4f24b272c
commit 696d19d5db
4 changed files with 40 additions and 1 deletions

View file

@ -1735,6 +1735,10 @@ extern Status XInitThreads(
void
);
extern Status XFreeThreads(
void
);
extern void XLockDisplay(
Display* /* display */
);

View file

@ -52,6 +52,8 @@ XInitThreads, XLockDisplay, XUnlockDisplay \- multi-threading support
.HP
Status XInitThreads\^(void);
.HP
Status XFreeThreads\^(void);
.HP
void XLockDisplay\^(\^Display *\fIdisplay\fP\^);
.HP
void XUnlockDisplay\^(\^Display *\fIdisplay\fP\^);
@ -76,7 +78,11 @@ are protected by some other access mechanism (for example,
a mutual exclusion lock in a toolkit or through explicit client
programming), Xlib thread initialization is not required.
It is recommended that single-threaded programs not call this function.
.LP
The
.B XFreeThreads
function frees the memory allocated by
.BR XInitThreads .
.LP
The
.B XLockDisplay

View file

@ -105,4 +105,10 @@ xlib_ctor(void)
{
XInitThreads();
}
__attribute__((destructor)) static void
xlib_dtor(void)
{
XFreeThreads();
}
#endif

View file

@ -673,9 +673,32 @@ Status XInitThreads(void)
return 1;
}
Status XFreeThreads(void)
{
if (global_lock.lock != NULL) {
xmutex_free(global_lock.lock);
global_lock.lock = NULL;
}
if (i18n_lock.lock != NULL) {
xmutex_free(i18n_lock.lock);
i18n_lock.lock = NULL;
}
if (conv_lock.lock != NULL) {
xmutex_free(conv_lock.lock);
conv_lock.lock = NULL;
}
return 1;
}
#else /* XTHREADS */
Status XInitThreads(void)
{
return 0;
}
Status XFreeThreads(void)
{
return 0;
}
#endif /* XTHREADS */