buffer.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 1k
Category:

Windows Kernel

Development Platform:

Visual C++

  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. }