Module: wine Branch: master Commit: 25a9e2c6e24d4f369b3c31f7e1a0c6d7534438cd URL: http://source.winehq.org/git/wine.git/?a=commit;h=25a9e2c6e24d4f369b3c31f7e1...
Author: Bruno Jesus 00cpxxx@gmail.com Date: Mon Jan 30 04:59:41 2017 -0200
wlanapi: Implement WlanAllocateMemory/WlanFreeMemory with tests.
Signed-off-by: Bruno Jesus 00cpxxx@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wlanapi/main.c | 25 +++++++++++++++++++++++++ dlls/wlanapi/tests/wlanapi.c | 18 ++++++++++++++++++ dlls/wlanapi/wlanapi.spec | 4 ++-- include/wlanapi.h | 2 ++ 4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/dlls/wlanapi/main.c b/dlls/wlanapi/main.c index cf6a684..5eeb515 100644 --- a/dlls/wlanapi/main.c +++ b/dlls/wlanapi/main.c @@ -46,6 +46,31 @@ DWORD WINAPI WlanOpenHandle(DWORD client_version, void *reserved, DWORD *negotia return ERROR_CALL_NOT_IMPLEMENTED; }
+void WINAPI WlanFreeMemory(void *ptr) +{ + TRACE("(%p)\n", ptr); + + HeapFree(GetProcessHeap(), 0, ptr); +} + +void *WINAPI WlanAllocateMemory(DWORD size) +{ + void *ret; + + TRACE("(%d)", size); + + if (!size) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + ret = HeapAlloc(GetProcessHeap(), 0, size); + if (!ret) + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + + return ret; +}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, void *reserved) { diff --git a/dlls/wlanapi/tests/wlanapi.c b/dlls/wlanapi/tests/wlanapi.c index c0bc658..a35a7c9 100644 --- a/dlls/wlanapi/tests/wlanapi.c +++ b/dlls/wlanapi/tests/wlanapi.c @@ -94,6 +94,23 @@ todo_wine { } }
+static void test_WlanAllocateFreeMemory(void) +{ + void *ptr; + + SetLastError(0xdeadbeef); + ptr = WlanAllocateMemory(0); + ok(ptr == NULL, "Expected NULL, got %p\n", ptr); + ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", GetLastError()); + + ptr = WlanAllocateMemory(1024); + ok(ptr != NULL, "Expected non-NULL\n"); + + WlanFreeMemory(ptr); + + WlanFreeMemory(NULL); /* return is void, proves that won't crash */ +} + START_TEST(wlanapi) { HANDLE handle; @@ -108,4 +125,5 @@ START_TEST(wlanapi) }
test_WlanOpenHandle(); + test_WlanAllocateFreeMemory(); } diff --git a/dlls/wlanapi/wlanapi.spec b/dlls/wlanapi/wlanapi.spec index 59454f4..a11b857 100644 --- a/dlls/wlanapi/wlanapi.spec +++ b/dlls/wlanapi/wlanapi.spec @@ -1,11 +1,11 @@ -@ stub WlanAllocateMemory +@ stdcall WlanAllocateMemory(long) @ stdcall WlanCloseHandle(ptr ptr) @ stub WlanConnect @ stub WlanDeleteProfile @ stub WlanDisconnect @ stdcall WlanEnumInterfaces(long ptr ptr) @ stub WlanExtractPsdIEDataList -@ stub WlanFreeMemory +@ stdcall WlanFreeMemory(ptr) @ stub WlanGetAvailableNetworkList @ stub WlanGetFilterList @ stub WlanGetInterfaceCapability diff --git a/include/wlanapi.h b/include/wlanapi.h index 73b4583..f6ef60d 100644 --- a/include/wlanapi.h +++ b/include/wlanapi.h @@ -48,5 +48,7 @@ typedef struct _WLAN_INTERFACE_INFO_LIST DWORD WINAPI WlanCloseHandle(HANDLE, void *); DWORD WINAPI WlanEnumInterfaces(HANDLE, void *, WLAN_INTERFACE_INFO_LIST **); DWORD WINAPI WlanOpenHandle(DWORD, void *, DWORD *, HANDLE *); +void *WINAPI WlanAllocateMemory(DWORD); +void WINAPI WlanFreeMemory(void *);
#endif /* _WLAN_WLANAPI_H */