internal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /////////////////////////////////////////////////////////////////////////EA-V1
  19. // $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/internal.h $
  20. // $Author: mhoffe $
  21. // $Revision: #1 $
  22. // $DateTime: 2003/07/03 11:55:26 $
  23. //
  24. // ©2003 Electronic Arts
  25. //
  26. // Internal header
  27. //////////////////////////////////////////////////////////////////////////////
  28. #ifdef _MSC_VER
  29. # pragma once
  30. #endif
  31. #ifndef INTERNAL_H // Include guard
  32. #define INTERNAL_H
  33. // make sure we're not omitting the frame pointer
  34. #pragma optimize("y",off)
  35. // We're doing our own little internal asserts for full debug
  36. // builds (until this library is proven & stable)
  37. #ifdef _DEBUG
  38. # define __ASSERT(x) do { if (!(x)) DebugInternalAssert(__FILE__,__LINE__,#x); } while (0)
  39. #else
  40. # define __ASSERT(x) do { } while(0)
  41. #endif
  42. /** \internal
  43. Internal assert function for module internal assertions.
  44. \param file file name
  45. \param line line number
  46. \param expr expression which failed
  47. */
  48. void DebugInternalAssert(const char *file, int line, const char *expr);
  49. /** \internal
  50. Allocate the given number of bytes from the Windows heap.
  51. This function performs a controlled crash on failure.
  52. \param numBytes number of bytes to allocate
  53. \return pointer to allocated memory
  54. */
  55. void *DebugAllocMemory(unsigned numBytes);
  56. /** \internal
  57. Allocates/reallocates the given memory block to the new
  58. given size.
  59. This function performs a controlled crash on failure.
  60. \param oldPtr pointer to old memory block, may be NULL
  61. \param newSize new size of block
  62. \return pointer to reallocated memory
  63. */
  64. void *DebugReAllocMemory(void *oldPtr, unsigned newSize);
  65. /** \internal
  66. Frees the allocated memory block.
  67. This function never fails.
  68. \param ptr memory block to free
  69. */
  70. void DebugFreeMemory(void *ptr);
  71. /// \internal Command group: 'debug'
  72. class DebugCmdInterfaceDebug: public DebugCmdInterface
  73. {
  74. public:
  75. virtual bool Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode,
  76. unsigned argn, const char * const * argv);
  77. virtual void Delete(void)
  78. {
  79. this->~DebugCmdInterfaceDebug();
  80. DebugFreeMemory(this);
  81. }
  82. };
  83. #endif // INTERNAL_H