Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. #include "initializer.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. #if 0
  13. Initializer *Initializer::s_pInitializers = 0;
  14. Initializer::Initializer(void **pVar, CreateInitializerObjectFn createFn, DeleteInitializerObjectFn deleteFn)
  15. {
  16. m_pVar = pVar;
  17. m_CreateFn = createFn;
  18. m_DeleteFn = deleteFn;
  19. m_pNext = s_pInitializers;
  20. s_pInitializers = this;
  21. }
  22. bool Initializer::InitializeAllObjects()
  23. {
  24. for(Initializer *pCur=s_pInitializers; pCur; pCur=pCur->m_pNext)
  25. {
  26. if(void *ptr = pCur->m_CreateFn())
  27. {
  28. *pCur->m_pVar = ptr;
  29. }
  30. else
  31. {
  32. // Don't worry if we're not actually trying to initialize a global
  33. if (pCur->m_pVar)
  34. {
  35. FreeAllObjects();
  36. return false;
  37. }
  38. }
  39. }
  40. return true;
  41. }
  42. void Initializer::FreeAllObjects()
  43. {
  44. for(Initializer *pCur=s_pInitializers; pCur; pCur=pCur->m_pNext)
  45. {
  46. if (pCur->m_pVar)
  47. {
  48. pCur->m_DeleteFn(*pCur->m_pVar);
  49. *pCur->m_pVar = 0;
  50. }
  51. }
  52. }
  53. #endif