home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / CLASSSRC.PAK / HEAPSEL.CPP < prev    next >
C/C++ Source or Header  |  1995-08-29  |  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.