Commit 134935e7 authored by Qian Hong's avatar Qian Hong Committed by Alexandre Julliard

imm32: Fixed IMCC implementation.

parent 1448d95f
......@@ -37,12 +37,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(imm);
typedef struct tagIMCCInternal
{
DWORD dwLock;
DWORD dwSize;
} IMCCInternal;
#define MAKE_FUNCPTR(f) typeof(f) * p##f
typedef struct _tagImmHkl{
struct list entry;
......@@ -2625,15 +2619,7 @@ DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC)
*/
HIMCC WINAPI ImmCreateIMCC(DWORD size)
{
IMCCInternal *internal;
int real_size = size + sizeof(IMCCInternal);
internal = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, real_size);
if (internal == NULL)
return NULL;
internal->dwSize = size;
return internal;
return GlobalAlloc(GMEM_ZEROINIT | GMEM_MOVEABLE, size);
}
/***********************************************************************
......@@ -2641,8 +2627,7 @@ HIMCC WINAPI ImmCreateIMCC(DWORD size)
*/
HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
{
HeapFree(GetProcessHeap(),0,block);
return NULL;
return GlobalFree(block);
}
/***********************************************************************
......@@ -2650,11 +2635,7 @@ HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
*/
LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
{
IMCCInternal *internal;
internal = imcc;
internal->dwLock ++;
return internal + 1;
return GlobalLock(imcc);
}
/***********************************************************************
......@@ -2662,12 +2643,7 @@ LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
*/
BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
{
IMCCInternal *internal;
internal = imcc;
if (internal->dwLock)
internal->dwLock --;
return (internal->dwLock!=0);
return GlobalUnlock(imcc);
}
/***********************************************************************
......@@ -2675,10 +2651,7 @@ BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
*/
DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
{
IMCCInternal *internal;
internal = imcc;
return internal->dwLock;
return GlobalFlags(imcc) & GMEM_LOCKCOUNT;
}
/***********************************************************************
......@@ -2686,15 +2659,7 @@ DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
*/
HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
{
IMCCInternal *internal,*newone;
int real_size = size + sizeof(IMCCInternal);
internal = imcc;
newone = HeapReAlloc(GetProcessHeap(), 0, internal, real_size);
newone->dwSize = size;
return newone;
return GlobalReAlloc(imcc, size, GMEM_ZEROINIT | GMEM_MOVEABLE);
}
/***********************************************************************
......@@ -2702,10 +2667,7 @@ HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
*/
DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
{
IMCCInternal *internal;
internal = imcc;
return internal->dwSize;
return GlobalSize(imcc);
}
/***********************************************************************
......
......@@ -734,25 +734,25 @@ static void test_ImmGetIMCCLockCount(void)
ok(count == 0, "expect 0, returned %d\n", count);
p = ImmLockIMCC(imcc);
todo_wine ok(GlobalHandle(p) == imcc, "expect %p, returned %p\n", imcc, GlobalHandle(p));
ok(GlobalHandle(p) == imcc, "expect %p, returned %p\n", imcc, GlobalHandle(p));
for (i = 0; i < GMEM_LOCKCOUNT * 2; i++)
{
ImmLockIMCC(imcc);
count = ImmGetIMCCLockCount(imcc);
g_count = GlobalFlags(imcc) & GMEM_LOCKCOUNT;
todo_wine ok(count == g_count, "count %d, g_count %d\n", count, g_count);
ok(count == g_count, "count %d, g_count %d\n", count, g_count);
}
count = ImmGetIMCCLockCount(imcc);
todo_wine ok(count == GMEM_LOCKCOUNT, "expect GMEM_LOCKCOUNT, returned %d\n", count);
ok(count == GMEM_LOCKCOUNT, "expect GMEM_LOCKCOUNT, returned %d\n", count);
for (i = 0; i < GMEM_LOCKCOUNT - 1; i++)
GlobalUnlock(imcc);
count = ImmGetIMCCLockCount(imcc);
todo_wine ok(count == 1, "expect 1, returned %d\n", count);
ok(count == 1, "expect 1, returned %d\n", count);
GlobalUnlock(imcc);
count = ImmGetIMCCLockCount(imcc);
todo_wine ok(count == 0, "expect 0, returned %d\n", count);
ok(count == 0, "expect 0, returned %d\n", count);
ImmDestroyIMCC(imcc);
}
......@@ -775,18 +775,18 @@ static void test_ImmDestroyIMCC(void)
p = ImmDestroyIMCC(imcc);
ok(p == NULL, "Destroy a locked IMCC should success!\n");
p = ImmLockIMCC(imcc);
todo_wine ok(p == NULL, "Lock a destroyed IMCC should fail!\n");
ok(p == NULL, "Lock a destroyed IMCC should fail!\n");
ret = ImmUnlockIMCC(imcc);
todo_wine ok(ret == FALSE, "Unlock a destroyed IMCC should return FALSE!\n");
ok(ret == FALSE, "Unlock a destroyed IMCC should return FALSE!\n");
count = ImmGetIMCCLockCount(imcc);
todo_wine ok(count == 0, "Get lock count of a destroyed IMCC should return 0!\n");
ok(count == 0, "Get lock count of a destroyed IMCC should return 0!\n");
size = ImmGetIMCCSize(imcc);
todo_wine ok(size == 0, "Get size of a destroyed IMCC should return 0!\n");
ok(size == 0, "Get size of a destroyed IMCC should return 0!\n");
SetLastError(0xdeadbeef);
p = ImmDestroyIMCC(imcc);
todo_wine ok(p != NULL, "returned NULL\n");
ok(p != NULL, "returned NULL\n");
ret = GetLastError();
todo_wine ok(ret == ERROR_INVALID_HANDLE, "wrong last error %08x!\n", ret);
ok(ret == ERROR_INVALID_HANDLE, "wrong last error %08x!\n", ret);
}
static void test_ImmMessages(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment