From: Vibhav Pant vibhavp@gmail.com
--- dlls/vccorlib140/tests/vccorlib.c | 23 +++++++++++++++++++++++ dlls/vccorlib140/vccorlib.c | 20 ++++++++++++++++++++ dlls/vccorlib140/vccorlib140.spec | 8 ++++---- 3 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/dlls/vccorlib140/tests/vccorlib.c b/dlls/vccorlib140/tests/vccorlib.c index 890472f0b46..56f054a0596 100644 --- a/dlls/vccorlib140/tests/vccorlib.c +++ b/dlls/vccorlib140/tests/vccorlib.c @@ -60,6 +60,8 @@ static HRESULT (__cdecl *pInitializeData)(int); static void (__cdecl *pUninitializeData)(int); static HRESULT (WINAPI *pGetActivationFactoryByPCWSTR)(const WCHAR *, const GUID *, void **); static HRESULT (WINAPI *pGetIidsFn)(UINT32, UINT32 *, const GUID *, GUID **); +static void *(__cdecl *pAllocate)(size_t); +static void (__cdecl *pFree)(void *);
static BOOL init(void) { @@ -88,16 +90,22 @@ static BOOL init(void) pGetActivationFactoryByPCWSTR = (void *)GetProcAddress(hmod, "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z"); pGetIidsFn = (void *)GetProcAddress(hmod, "?GetIidsFn@@YAJHPEAKPEBU__s_GUID@@PEAPEAVGuid@Platform@@@Z"); + pAllocate = (void *)GetProcAddress(hmod, "?Allocate@Heap@Details@Platform@@SAPEAX_K@Z"); + pFree = (void *)GetProcAddress(hmod, "?Free@Heap@Details@Platform@@SAXPEAX@Z"); } else { pGetActivationFactoryByPCWSTR = (void *)GetProcAddress(hmod, "?GetActivationFactoryByPCWSTR@@YGJPAXAAVGuid@Platform@@PAPAX@Z"); pGetIidsFn = (void *)GetProcAddress(hmod, "?GetIidsFn@@YGJHPAKPBU__s_GUID@@PAPAVGuid@Platform@@@Z"); + pAllocate = (void *)GetProcAddress(hmod, "?Allocate@Heap@Details@Platform@@SAPAXI@Z"); + pFree = (void *)GetProcAddress(hmod, "?Free@Heap@Details@Platform@@SAXPAX@Z"); } #endif ok(pGetActivationFactoryByPCWSTR != NULL, "GetActivationFactoryByPCWSTR not available\n"); ok(pGetIidsFn != NULL, "GetIidsFn not available\n"); + ok(pAllocate != NULL, "Allocate not available\n"); + ok(pFree != NULL, "Free not available\n");
return TRUE; } @@ -293,6 +301,20 @@ static void test_GetIidsFn(void) CoTaskMemFree(guids_dest); }
+static void test_Allocate(void) +{ + void *addr; + + addr = pAllocate(0); + ok(!!addr, "got addr %p\n", addr); + pFree(addr); + + addr = pAllocate(sizeof(void *)); + ok(!!addr, "got addr %p\n", addr); + pFree(addr); + pFree(NULL); +} + START_TEST(vccorlib) { if(!init()) @@ -301,4 +323,5 @@ START_TEST(vccorlib) test_InitializeData(); test_GetActivationFactoryByPCWSTR(); test_GetIidsFn(); + test_Allocate(); } diff --git a/dlls/vccorlib140/vccorlib.c b/dlls/vccorlib140/vccorlib.c index 23310ec542e..6bae9660302 100644 --- a/dlls/vccorlib140/vccorlib.c +++ b/dlls/vccorlib140/vccorlib.c @@ -73,3 +73,23 @@ HRESULT WINAPI GetIidsFn(unsigned int count, unsigned int *copied, const GUID *s
return S_OK; } + +void *__cdecl Allocate(size_t size) +{ + void *addr; + + TRACE("(%Iu)\n", size); + + addr = malloc(size); + /* TODO: Throw a COMException on allocation failure. */ + if (!addr) + FIXME("allocation failure\n"); + return addr; +} + +void __cdecl Free(void *addr) +{ + TRACE("(%p)\n", addr); + + free(addr); +} diff --git a/dlls/vccorlib140/vccorlib140.spec b/dlls/vccorlib140/vccorlib140.spec index 503b2771ee7..e5dcd9b5a8b 100644 --- a/dlls/vccorlib140/vccorlib140.spec +++ b/dlls/vccorlib140/vccorlib140.spec @@ -66,8 +66,8 @@ @ stub -arch=i386 ?FlushFactoryCache@@YGXXZ @ stub -arch=arm ?FlushFactoryCache@@YAXXZ @ stub -arch=win64 ?FlushFactoryCache@@YAXXZ -@ stub -arch=win32 ?Free@Heap@Details@Platform@@SAXPAX@Z -@ stub -arch=win64 ?Free@Heap@Details@Platform@@SAXPEAX@Z +@ cdecl -arch=win32 ?Free@Heap@Details@Platform@@SAXPAX@Z(ptr) Free +@ cdecl -arch=win64 ?Free@Heap@Details@Platform@@SAXPEAX@Z(ptr) Free @ stub -arch=win32 ?FreeException@Heap@Details@Platform@@SAXPAX@Z @ stub -arch=win64 ?FreeException@Heap@Details@Platform@@SAXPEAX@Z @ stub -arch=i386 ?GetActivationFactory@Details@Platform@@YGJPAVModuleBase@1WRL@Microsoft@@PAUHSTRING__@@PAPAUIActivationFactory@@@Z @@ -501,10 +501,10 @@ @ stub -arch=win64 ?AlignedFree@Heap@Details@Platform@@SAXPEAX@Z @ stub -arch=win32 ?AlignedFreeException@Heap@Details@Platform@@SAXPAX@Z @ stub -arch=win64 ?AlignedFreeException@Heap@Details@Platform@@SAXPEAX@Z -@ stub -arch=win32 ?Allocate@Heap@Details@Platform@@SAPAXI@Z +@ cdecl -arch=win32 ?Allocate@Heap@Details@Platform@@SAPAXI@Z(long) Allocate @ stub -arch=win64 ?Allocate@Heap@Details@Platform@@SAPEAX_K0@Z @ stub -arch=win32 ?Allocate@Heap@Details@Platform@@SAPAXII@Z -@ stub -arch=win64 ?Allocate@Heap@Details@Platform@@SAPEAX_K@Z +@ cdecl -arch=win64 ?Allocate@Heap@Details@Platform@@SAPEAX_K@Z(long) Allocate @ stub -arch=win32 ?AllocateException@Heap@Details@Platform@@SAPAXI@Z @ stub -arch=win64 ?AllocateException@Heap@Details@Platform@@SAPEAX_K0@Z @ stub -arch=win32 ?AllocateException@Heap@Details@Platform@@SAPAXII@Z