Source code of Windows XP (NT5)
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.

52 lines
1005 B

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /* BUFFER.CPP -- Implementation of BUFFER class.
  6. *
  7. * History:
  8. * 03/24/93 gregj Created
  9. * 10/25/93 gregj Use shell232.dll routines
  10. */
  11. #include "npcommon.h"
  12. #include "buffer.h"
  13. #include <netlib.h>
  14. BOOL BUFFER::Alloc( UINT cbBuffer )
  15. {
  16. _lpBuffer = (LPSTR)::MemAlloc(cbBuffer);
  17. if (_lpBuffer != NULL) {
  18. _cb = cbBuffer;
  19. return TRUE;
  20. }
  21. return FALSE;
  22. }
  23. BOOL BUFFER::Realloc( UINT cbNew )
  24. {
  25. LPVOID lpNew = ::MemReAlloc(_lpBuffer, cbNew);
  26. if (lpNew == NULL)
  27. return FALSE;
  28. _lpBuffer = (LPSTR)lpNew;
  29. _cb = cbNew;
  30. return TRUE;
  31. }
  32. BUFFER::BUFFER( UINT cbInitial /* =0 */ )
  33. : BUFFER_BASE(),
  34. _lpBuffer( NULL )
  35. {
  36. if (cbInitial)
  37. Alloc( cbInitial );
  38. }
  39. BUFFER::~BUFFER()
  40. {
  41. if (_lpBuffer != NULL) {
  42. ::MemFree(_lpBuffer);
  43. _lpBuffer = NULL;
  44. }
  45. }