https://git.reactos.org/?p=reactos.git;a=commitdiff;h=008745d951ac973060cbc0ff5aa456f384f7bd73

commit 008745d951ac973060cbc0ff5aa456f384f7bd73
Author:     Mark Jansen <[email protected]>
AuthorDate: Wed Jan 8 23:26:06 2020 +0100
Commit:     Mark Jansen <[email protected]>
CommitDate: Sat Feb 8 22:09:14 2020 +0100

    [ATL][ATL_APITEST] Test + implement CHeapPtrList
---
 modules/rostests/apitests/atl/CComVariant.cpp      |   1 +
 modules/rostests/apitests/atl/CHeapPtrList.cpp     | 117 ++++++++++++++
 modules/rostests/apitests/atl/CMakeLists.txt       |   3 +-
 modules/rostests/apitests/atl/devenv/ATLTest.sln   |  10 ++
 .../apitests/atl/devenv/CHeapPtrList.vcxproj       | 180 +++++++++++++++++++++
 modules/rostests/apitests/atl/testlist.c           |   2 +
 sdk/lib/atl/atlcoll.h                              |  28 ++++
 7 files changed, 340 insertions(+), 1 deletion(-)

diff --git a/modules/rostests/apitests/atl/CComVariant.cpp 
b/modules/rostests/apitests/atl/CComVariant.cpp
index cd6cd605301..77e217e57c5 100644
--- a/modules/rostests/apitests/atl/CComVariant.cpp
+++ b/modules/rostests/apitests/atl/CComVariant.cpp
@@ -6,6 +6,7 @@
  */
 
 /* In case we are building against the MS headers, we need to disable 
assertions. */
+#undef ATLASSERT
 #define ATLASSERT(x)
 #define _ATL_NO_VARIANT_THROW
 
diff --git a/modules/rostests/apitests/atl/CHeapPtrList.cpp 
b/modules/rostests/apitests/atl/CHeapPtrList.cpp
new file mode 100644
index 00000000000..41da433b427
--- /dev/null
+++ b/modules/rostests/apitests/atl/CHeapPtrList.cpp
@@ -0,0 +1,117 @@
+/*
+ * PROJECT:     ReactOS api tests
+ * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
+ * PURPOSE:     Test for CHeapPtrList
+ * COPYRIGHT:   Copyright 2020 Mark Jansen ([email protected])
+ */
+
+#ifdef HAVE_APITEST
+#include <apitest.h>
+#else
+#include "atltest.h"
+#endif
+#include <atlcoll.h>
+
+static PDWORD
+test_Alloc(DWORD value)
+{
+    PDWORD ptr = (PDWORD)::CoTaskMemAlloc(sizeof(DWORD));
+    *ptr = value;
+    return ptr;
+}
+
+// We use the CComAllocator, so we can easily spy on it
+template <typename T>
+class CComHeapPtrList :
+    public CHeapPtrList<T, CComAllocator>
+{
+public:
+    CComHeapPtrList(_In_ UINT nBlockSize = 10) throw()
+        :CHeapPtrList<T, CComAllocator>(nBlockSize)
+    {
+    }
+};
+
+
+
+static LONG g_OpenAllocations = 0;
+static LONG g_Reallocations = 0;
+
+struct CHeapPtrListMallocSpy : public IMallocSpy
+{
+    STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject)
+    {
+        if (IsEqualGUID(riid, IID_IMallocSpy))
+        {
+            *ppvObject = this;
+        }
+        return S_OK;
+    }
+
+    virtual ULONG STDMETHODCALLTYPE AddRef() { return 1; }
+    virtual ULONG STDMETHODCALLTYPE Release() { return 1; }
+    virtual SIZE_T STDMETHODCALLTYPE PreAlloc(SIZE_T cbRequest) { return 
cbRequest; }
+    virtual LPVOID STDMETHODCALLTYPE PostAlloc(LPVOID pActual)
+    {
+        InterlockedIncrement(&g_OpenAllocations);
+        return pActual;
+    }
+    virtual LPVOID STDMETHODCALLTYPE PreFree(LPVOID pRequest, BOOL) { return 
pRequest; }
+    virtual void STDMETHODCALLTYPE PostFree(BOOL fSpyed)
+    {
+        if (fSpyed)
+            InterlockedDecrement(&g_OpenAllocations);
+    }
+    virtual SIZE_T STDMETHODCALLTYPE PreRealloc(LPVOID pRequest, SIZE_T 
cbRequest, LPVOID *ppNewRequest, BOOL)
+    {
+        *ppNewRequest = pRequest;
+        return cbRequest;
+    }
+    virtual LPVOID STDMETHODCALLTYPE PostRealloc(LPVOID pActual, BOOL fSpyed)
+    {
+        if (fSpyed)
+            InterlockedIncrement(&g_Reallocations);
+        return pActual;
+    }
+    virtual LPVOID STDMETHODCALLTYPE PreGetSize(LPVOID pRequest, BOOL) { 
return pRequest; }
+    virtual SIZE_T STDMETHODCALLTYPE PostGetSize(SIZE_T cbActual, BOOL) { 
return cbActual; }
+    virtual LPVOID STDMETHODCALLTYPE PreDidAlloc(LPVOID pRequest, BOOL) { 
return pRequest; }
+    virtual int STDMETHODCALLTYPE PostDidAlloc(LPVOID, BOOL, int fActual) { 
return fActual; }
+    virtual void STDMETHODCALLTYPE PreHeapMinimize() {}
+    virtual void STDMETHODCALLTYPE PostHeapMinimize() {}
+};
+
+static CHeapPtrListMallocSpy g_Spy;
+
+
+START_TEST(CHeapPtrList)
+{
+    HRESULT hr = CoRegisterMallocSpy(&g_Spy);
+    ok(SUCCEEDED(hr), "Expected CoRegisterMallocSpy to succeed, but it failed: 
0x%lx\n", hr);
+
+    {
+        ok(g_OpenAllocations == 0, "Expected there to be 0 allocations, was: 
%ld\n", g_OpenAllocations);
+        CComHeapPtrList<DWORD> heapPtr1;
+        ok(g_OpenAllocations == 0, "Expected there to be 0 allocations, was: 
%ld\n", g_OpenAllocations);
+        PDWORD Ptr = test_Alloc(0x11111111);
+        ok(g_OpenAllocations == 1, "Expected there to be 1 allocations, was: 
%ld\n", g_OpenAllocations);
+        CComHeapPtr<DWORD> tmp(Ptr);
+        ok(g_OpenAllocations == 1, "Expected there to be 1 allocations, was: 
%ld\n", g_OpenAllocations);
+        heapPtr1.AddTail(tmp);
+        ok(tmp.m_pData == NULL, "Expected m_pData to be transfered\n");
+        ok(g_OpenAllocations == 1, "Expected there to be 1 allocations, was: 
%ld\n", g_OpenAllocations);
+        Ptr = test_Alloc(0x22222222);
+        ok(g_OpenAllocations == 2, "Expected there to be 1 allocations, was: 
%ld\n", g_OpenAllocations);
+#ifdef _MSC_VER
+        heapPtr1.AddTail(CComHeapPtr<DWORD>(Ptr));
+#else
+        CComHeapPtr<DWORD> xxx(Ptr);
+        heapPtr1.AddTail(xxx);
+#endif
+        ok(g_OpenAllocations == 2, "Expected there to be 1 allocations, was: 
%ld\n", g_OpenAllocations);
+    }
+    ok(g_OpenAllocations == 0, "Expected there to be 0 allocations, was: 
%ld\n", g_OpenAllocations);
+
+    hr = CoRevokeMallocSpy();
+    ok(SUCCEEDED(hr), "Expected CoRevokeMallocSpy to succeed, but it failed: 
0x%lx\n", hr);
+}
diff --git a/modules/rostests/apitests/atl/CMakeLists.txt 
b/modules/rostests/apitests/atl/CMakeLists.txt
index 8bbd802c4a5..b3e12092ece 100644
--- a/modules/rostests/apitests/atl/CMakeLists.txt
+++ b/modules/rostests/apitests/atl/CMakeLists.txt
@@ -13,6 +13,8 @@ list(APPEND SOURCE
     CComHeapPtr.cpp
     CComObject.cpp
     CComQIPtr.cpp
+    CComVariant.cpp
+    CHeapPtrList.cpp
     CImage.cpp
     CRegKey.cpp
     CSimpleArray.cpp
@@ -22,7 +24,6 @@ list(APPEND SOURCE
 
 add_executable(atl_apitest
     ${SOURCE}
-    CComVariant.cpp
     testlist.c
     atl_apitest.rc)
 
diff --git a/modules/rostests/apitests/atl/devenv/ATLTest.sln 
b/modules/rostests/apitests/atl/devenv/ATLTest.sln
index 125d96ce315..8fd0e07a092 100644
--- a/modules/rostests/apitests/atl/devenv/ATLTest.sln
+++ b/modules/rostests/apitests/atl/devenv/ATLTest.sln
@@ -21,6 +21,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = 
"CAtlArray", "CAtlArray.vcxp
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CAtlList", 
"CAtlList.vcxproj", "{00C3325D-0E3D-43F1-92C8-F7D5C32F70C6}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CHeapPtrList", 
"CHeapPtrList.vcxproj", "{83D1D036-02AC-4DC5-B061-1F47F7065661}"
+EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CComHeapPtr", 
"CComHeapPtr.vcxproj", "{F10E34E3-FB53-4650-985A-28BD1905D65C}"
 EndProject
 Global
@@ -103,6 +105,14 @@ Global
                {00C3325D-0E3D-43F1-92C8-F7D5C32F70C6}.Release|x64.Build.0 = 
Release|x64
                {00C3325D-0E3D-43F1-92C8-F7D5C32F70C6}.Release|x86.ActiveCfg = 
Release|Win32
                {00C3325D-0E3D-43F1-92C8-F7D5C32F70C6}.Release|x86.Build.0 = 
Release|Win32
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Debug|x64.ActiveCfg = 
Debug|x64
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Debug|x64.Build.0 = 
Debug|x64
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Debug|x86.ActiveCfg = 
Debug|Win32
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Debug|x86.Build.0 = 
Debug|Win32
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Release|x64.ActiveCfg = 
Release|x64
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Release|x64.Build.0 = 
Release|x64
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Release|x86.ActiveCfg = 
Release|Win32
+               {83D1D036-02AC-4DC5-B061-1F47F7065661}.Release|x86.Build.0 = 
Release|Win32
                {F10E34E3-FB53-4650-985A-28BD1905D65C}.Debug|x64.ActiveCfg = 
Debug|x64
                {F10E34E3-FB53-4650-985A-28BD1905D65C}.Debug|x64.Build.0 = 
Debug|x64
                {F10E34E3-FB53-4650-985A-28BD1905D65C}.Debug|x86.ActiveCfg = 
Debug|Win32
diff --git a/modules/rostests/apitests/atl/devenv/CHeapPtrList.vcxproj 
b/modules/rostests/apitests/atl/devenv/CHeapPtrList.vcxproj
new file mode 100644
index 00000000000..28f9f52ab5e
--- /dev/null
+++ b/modules/rostests/apitests/atl/devenv/CHeapPtrList.vcxproj
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{83D1D036-02AC-4DC5-B061-1F47F7065661}</ProjectGuid>
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+    <Keyword>AtlProj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" 
Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" 
Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" 
Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+    <PlatformToolset>v140_xp</PlatformToolset>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 
Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140_xp</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" 
Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" 
Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" 
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" 
Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" 
Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <IgnoreImportLibrary>true</IgnoreImportLibrary>
+    <LinkIncremental>true</LinkIncremental>
+    <IntDir>$(ProjectName)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <IgnoreImportLibrary>true</IgnoreImportLibrary>
+    <LinkIncremental>true</LinkIncremental>
+    <IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <IgnoreImportLibrary>true</IgnoreImportLibrary>
+    <LinkIncremental>false</LinkIncremental>
+    <IntDir>$(ProjectName)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <IgnoreImportLibrary>true</IgnoreImportLibrary>
+    <LinkIncremental>false</LinkIncremental>
+    <IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
+  </PropertyGroup>
+  <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <ResourceCompile>
+      <Culture>0x0409</Culture>
+      
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ResourceCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <ResourceCompile>
+      <Culture>0x0409</Culture>
+      
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ResourceCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <ResourceCompile>
+      <Culture>0x0409</Culture>
+      
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ResourceCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PrecompiledHeader>NotUsing</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <ResourceCompile>
+      <Culture>0x0409</Culture>
+      
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ResourceCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="../CHeapPtrList.cpp">
+      <RuntimeLibrary 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
+      <RuntimeLibrary 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MultiThreaded</RuntimeLibrary>
+      <RuntimeLibrary 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
+      <RuntimeLibrary 
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader 
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+      <PrecompiledHeader 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/modules/rostests/apitests/atl/testlist.c 
b/modules/rostests/apitests/atl/testlist.c
index d9a88545f2c..028063f826e 100644
--- a/modules/rostests/apitests/atl/testlist.c
+++ b/modules/rostests/apitests/atl/testlist.c
@@ -10,6 +10,7 @@ extern void func_CComHeapPtr(void);
 extern void func_CComObject(void);
 extern void func_CComQIPtr(void);
 extern void func_CComVariant(void);
+extern void func_CHeapPtrList(void);
 extern void func_CImage(void);
 extern void func_CRegKey(void);
 extern void func_CSimpleArray(void);
@@ -27,6 +28,7 @@ const struct test winetest_testlist[] =
     { "CComObject", func_CComObject },
     { "CComQIPtr", func_CComQIPtr },
     { "CComVariant", func_CComVariant },
+    { "CHeapPtrList", func_CHeapPtrList },
     { "CImage", func_CImage },
     { "CRegKey", func_CRegKey },
     { "CSimpleArray", func_CSimpleArray },
diff --git a/sdk/lib/atl/atlcoll.h b/sdk/lib/atl/atlcoll.h
index 6775a0281a3..32b9b46362d 100644
--- a/sdk/lib/atl/atlcoll.h
+++ b/sdk/lib/atl/atlcoll.h
@@ -157,6 +157,17 @@ class CElementTraits :
 };
 
 
+template<typename T, class Allocator = CCRTAllocator>
+class CHeapPtrElementTraits :
+    public CDefaultElementTraits< CHeapPtr<T, Allocator> >
+{
+public:
+    typedef CHeapPtr<T, Allocator>& INARGTYPE;
+    typedef T*& OUTARGTYPE;
+};
+
+
+
 template<typename E, class ETraits = CElementTraits<E> >
 class CAtlArray
 {
@@ -852,6 +863,23 @@ typename CAtlList<E, ETraits>::CNode* CAtlList< E, 
ETraits>::GetFreeNode()
     return m_FreeNode;
 }
 
+
+template<typename E, class Allocator = CCRTAllocator >
+class CHeapPtrList :
+    public CAtlList<CHeapPtr<E, Allocator>, CHeapPtrElementTraits<E, 
Allocator> >
+{
+public:
+    CHeapPtrList(_In_ UINT nBlockSize = 10) :
+        CAtlList<CHeapPtr<E, Allocator>, CHeapPtrElementTraits<E, Allocator> 
>(nBlockSize)
+    {
+    }
+
+private:
+    CHeapPtrList(const CHeapPtrList&);
+    CHeapPtrList& operator=(const CHeapPtrList*);
+};
+
+
 }
 
 #endif
\ No newline at end of file

Reply via email to