BUFFER.CPP 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. ** Command & Conquer Red Alert(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. /***************************************************************************
  19. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : Westwood 32 Bit Library *
  23. * *
  24. * File Name : BUFFER.CPP *
  25. * *
  26. * Programmer : Phil W. Gorrow *
  27. * *
  28. * Start Date : May 18, 1994 *
  29. * *
  30. * Last Update : June 1, 1994 [PWG] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * BC::BufferClass -- The default (void) constructor for a buffer class *
  35. * BC::~BufferClass -- The destructor for the buffer class *
  36. * BC::BufferClass -- The standard constructor for a buffer class *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #ifndef BUFFER_H
  39. #include "buffer.h"
  40. #endif
  41. /*=========================================================================*/
  42. /* The following PRIVATE functions are in this file: */
  43. /*=========================================================================*/
  44. /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
  45. /***************************************************************************
  46. * BC::BufferClass -- The standard constructor for a buffer class *
  47. * *
  48. * INPUT: VOID * buffer to which should be included in buffer class *
  49. * LONG size of the buffer which we included *
  50. * *
  51. * OUTPUT: NONE *
  52. * *
  53. * WARNINGS: If the buffer passed to this function is equal to NULL, *
  54. * the buffer will be allocated using new. *
  55. * *
  56. * HISTORY: *
  57. * 06/01/1994 PWG : Created. *
  58. *=========================================================================*/
  59. BufferClass::BufferClass(VOID *buffer, LONG size)
  60. {
  61. Size = size; // find size of physical buffer
  62. if (buffer) { // if buffer is specified
  63. Buffer = (BYTE *)buffer; // point to it and mark
  64. Allocated = FALSE; // it as user allocated
  65. } else {
  66. Buffer = new BYTE[Size]; // otherwise allocate it and
  67. Allocated = TRUE; // mark it system alloced
  68. }
  69. }
  70. /***************************************************************************
  71. * BC::BufferClass -- constructor for BufferClass with size only *
  72. * *
  73. * INPUT: LONG the size of the buffer that needs to be allocated *
  74. * *
  75. * OUTPUT: none *
  76. * *
  77. * HISTORY: *
  78. * 06/01/1994 PWG : Created. *
  79. *=========================================================================*/
  80. BufferClass::BufferClass(LONG size)
  81. {
  82. Size = size;
  83. Buffer = new BYTE[Size]; // otherwise allocate it and
  84. Allocated = TRUE; // mark it system alloced
  85. }
  86. /***************************************************************************
  87. * BC::BufferClass -- The default (void) constructor for a buffer class *
  88. * *
  89. * INPUT: none *
  90. * *
  91. * OUTPUT: none *
  92. * *
  93. * NOTES: The primary function of this class is to be called by a *
  94. * derived class which will fill in the values after the *
  95. * fact. *
  96. * *
  97. * HISTORY: *
  98. * 06/01/1994 PWG : Created. *
  99. *=========================================================================*/
  100. BufferClass::BufferClass(VOID)
  101. {
  102. Buffer = NULL;
  103. Size = 0;
  104. Allocated = FALSE;
  105. }
  106. /***************************************************************************
  107. * BC::~BUFFERCLASS -- The destructor for the buffer class *
  108. * *
  109. * INPUT: none *
  110. * *
  111. * OUTPUT: none *
  112. * *
  113. * HISTORY: *
  114. * 06/01/1994 PWG : Created. *
  115. *=========================================================================*/
  116. BufferClass::~BufferClass(VOID)
  117. {
  118. if (Allocated) {
  119. delete[] Buffer;
  120. }
  121. }