Changeset 221


Ignore:
Timestamp:
Oct 2, 2013, 10:18:35 AM (10 years ago)
Author:
roman
Message:

CAutoPtr version by Igor M.

Location:
trunk/Utilities/Miscellaneous/StaticConstructor
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/Miscellaneous/StaticConstructor

    • Property svn:global-ignores
      •  

        old new  
        11Debug
        22ipch
         3Release
  • trunk/Utilities/Miscellaneous/StaticConstructor/StaticConstructor.cpp

    r220 r221  
    3737                m_nValue++;
    3838        }
     39
     40        ~CFoo()
     41        {
     42                _tprintf(_T("~CFoo()\n"));
     43        }
    3944};
    4045
    4146#define STATICLOCAL_PART1(type, name) \
    42         static BYTE g_pn##name##Data[sizeof (type)]; \
    43         static BOOL g_b##name##Initialized = FALSE; \
    44         type& g_##name = reinterpret_cast<type&>(g_pn##name##Data); \
     47        static type* g_p##name = NULL; \
    4548        { \
    4649                ATLASSERT(_pAtlModule); \
    4750                CComCritSecLock<CComCriticalSection> Lock(_pAtlModule->m_csStaticDataInitAndTypeInfo); \
    48                 if(!g_b##name##Initialized) \
     51                static CAutoPtr<type> g_pPrivate##name; \
     52                if(!g_p##name) \
    4953                { \
    50                         new (g_pn##name##Data) type(
     54                        g_pPrivate##name.Attach(new type(
    5155
    5256#define STATICLOCAL_PART2(type, name) \
    53                         ); \
    54                         g_b##name##Initialized = TRUE; \
     57                        )); \
     58                        g_p##name = (type*) g_pPrivate##name; \
    5559                } \
    56         }
     60        } \
     61        type& g_##name = *g_p##name;
    5762
    5863#define STATICLOCAL0(type, name) \
Note: See TracChangeset for help on using the changeset viewer.