summaryrefslogtreecommitdiff
path: root/core/src/xmake/thread/mutex_exit.c
diff options
context:
space:
mode:
authorruki <[email protected]>2025-08-28 22:28:18 +0800
committerruki <[email protected]>2025-08-28 11:35:54 +0800
commitc316009d37c853c070030823c257d1cbcf94ea48 (patch)
tree273f759f75957e3c27e8828e17623d24f713792c /core/src/xmake/thread/mutex_exit.c
parentc865267f3e781dc208f804efe8fa7f7fde53a064 (diff)
fix mutex cdata
Diffstat (limited to 'core/src/xmake/thread/mutex_exit.c')
-rw-r--r--core/src/xmake/thread/mutex_exit.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/core/src/xmake/thread/mutex_exit.c b/core/src/xmake/thread/mutex_exit.c
index 43c31c6c7..39d69ab8a 100644
--- a/core/src/xmake/thread/mutex_exit.c
+++ b/core/src/xmake/thread/mutex_exit.c
@@ -37,13 +37,10 @@ tb_int_t xm_thread_mutex_exit(lua_State* lua)
{
tb_assert_and_check_return_val(lua, 0);
- if (!xm_lua_ispointer(lua, 1))
- return 0;
+ xm_thread_mutex_t* thread_mutex = xm_thread_mutex_get(lua, 1);
+ tb_assert_and_check_return_val(thread_mutex && thread_mutex->handle, 0);
- xm_thread_mutex_t* thread_mutex = (xm_thread_mutex_t*)xm_lua_topointer(lua, 1);
- tb_check_return_val(thread_mutex, 0);
-
- if (thread_mutex && tb_atomic_fetch_and_sub(&thread_mutex->refn, 1) == 1)
+ if (tb_atomic_fetch_and_sub(&thread_mutex->refn, 1) == 1)
{
if (thread_mutex->handle)
{