home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / classsrc.pak / HEAPSEL.CPP < prev    next >
C/C++ Source or Header  |  1997-07-23  |  1KB  |  46 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  HEAPSEL.CPP                                                           */
  4. /*                                                                        */
  5. /*  Copyright (c) 1993, 1994 Borland International                        */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. //  THeapSelector doesn't have to do anything special under WIN32. It's
  11. //  only under Windows that we have to worry about multiple heaps.
  12.  
  13. #if !defined( __FLAT__ )
  14.  
  15. #if !defined( _Windows )
  16. #define _Windows
  17. #endif
  18.  
  19. #if !defined( __WINDOWS_H )
  20. #include <windows.h>
  21. #endif
  22.  
  23. #if !defined( __DOS_H )
  24. #include <dos.h>
  25. #endif
  26.  
  27. #if !defined( CLASSLIB_HEAPSEL_H )
  28. #include <classlib/heapsel.h>
  29. #endif
  30.  
  31. void _BIDSFARDATA *THeapSelector::Allocate( size_t sz ) const
  32. {
  33.     HeapSetup frame(FP_SEG(this));
  34.     return MK_FP( _DS, LocalAlloc( sz, LMEM_MOVEABLE ) );
  35. }
  36.  
  37. void THeapSelector::Free( void _BIDSFARDATA *block )
  38. {
  39.     HeapSetup frame(FP_SEG(block));
  40.     HANDLE hMem = LocalHandle( FP_OFF(block) );
  41.     if( hMem )
  42.         LocalFree( hMem );
  43. }
  44.  
  45. #endif
  46.