From 3c5777fbc6d521b7a6e8073704e3a75a20cfed8f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 29 Mar 2018 20:47:22 +0200 Subject: [PATCH] windows library: Add config for some Local* functions (#1139) Add configuration and tests for LocalAlloc, LocalFree and some other Local* functions. LocalReAlloc is currently not configured as an alloc/dealloc function (like realloc is not configured in std.cfg), i am not sure how to correctly configure it. --- cfg/windows.cfg | 77 ++++++++++++++++++++++++++++++++++++++++++++ test/cfg/windows.cpp | 16 +++++++++ 2 files changed, 93 insertions(+) diff --git a/cfg/windows.cfg b/cfg/windows.cfg index ab0ccf5b2..7a7d47c39 100644 --- a/cfg/windows.cfg +++ b/cfg/windows.cfg @@ -5098,6 +5098,83 @@ HFONT CreateFont( + + + false + + + + + 0: + + + + + + + + + + false + + + + + + + + + + + + 0: + + + + + false + + + + + + + + + false + + + + + + + + + + + false + + + + + + + + + + false + + + + + + + false diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index 8ce3a7278..b48d2a0b1 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -159,6 +159,10 @@ void validCode() SecureZeroMemory(byteBuf, sizeof(byteBuf)); RtlFillMemory(byteBuf, sizeof(byteBuf), 0xff); + // cppcheck-suppress LocalAllocCalled + HLOCAL pLocalAlloc = LocalAlloc(1, 2); + LocalFree(pLocalAlloc); + // Intrinsics __noop(); __noop(1, "test", NULL); @@ -326,6 +330,18 @@ void memleak_HeapAlloc() // cppcheck-suppress memleak } +void memleak_LocalAlloc() +{ + LPTSTR pszBuf; + // cppcheck-suppress LocalAllocCalled + pszBuf = (LPTSTR)LocalAlloc(LPTR, MAX_PATH*sizeof(TCHAR)); + (void)LocalSize(pszBuf); + (void)LocalFlags(pszBuf); + LocalLock(pszBuf); + LocalUnlock(pszBuf); + // cppcheck-suppress memleak +} + void resourceLeak_CreateSemaphoreA() { HANDLE hSemaphore;