[uim-commit] r1360 - trunk/uim
tkng at freedesktop.org
tkng at freedesktop.org
Wed Aug 31 02:10:37 PDT 2005
Author: tkng
Date: 2005-08-31 02:10:35 -0700 (Wed, 31 Aug 2005)
New Revision: 1360
Modified:
trunk/uim/uim.c
Log:
* uim/uim.c
-(context_array_mtx): New mutex.
-(get_context_id, put_context_id, uim_find_context): Added a lock by context_array_mtx.
Modified: trunk/uim/uim.c
===================================================================
--- trunk/uim/uim.c 2005-08-29 17:33:58 UTC (rev 1359)
+++ trunk/uim/uim.c 2005-08-31 09:10:35 UTC (rev 1360)
@@ -62,6 +62,7 @@
/* Definition of mutex */
UIM_NEW_MUTEX_STATIC(initing_or_quiting);
+UIM_NEW_MUTEX_STATIC(context_array_mtx);
void
uim_set_preedit_cb(uim_context uc,
@@ -80,20 +81,25 @@
get_context_id(uim_context uc)
{
int i;
+ UIM_LOCK_MUTEX(context_array_mtx);
for (i = 0; i < CONTEXT_ARRAY_SIZE; i++) {
if (!context_array[i]) {
context_array[i] = uc;
uc->id = i;
+ UIM_UNLOCK_MUTEX(context_array_mtx);
return;
}
}
uc->id = -1;
+ UIM_UNLOCK_MUTEX(context_array_mtx);
}
static void
put_context_id(uim_context uc)
{
+ UIM_LOCK_MUTEX(context_array_mtx);
context_array[uc->id] = NULL;
+ UIM_UNLOCK_MUTEX(context_array_mtx);
}
uim_context
@@ -272,7 +278,9 @@
uim_context
uim_find_context(int id)
{
+ UIM_LOCK_MUTEX(context_array_mtx);
return context_array[id];
+ UIM_UNLOCK_MUTEX(context_array_mtx);
}
int
More information about the uim-commit
mailing list