home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWMemory / Sources / FWPlatMe.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  1.4 KB  |  55 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPlatMe.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWPLATME_H
  13. #include <FWPlatMe.h>
  14. #endif
  15.  
  16. //========================================================================================
  17. // Global function definitions
  18. //========================================================================================
  19.  
  20. //----------------------------------------------------------------------------------------
  21. // PlatformAllocateBlock
  22. //----------------------------------------------------------------------------------------
  23.  
  24. void *PlatformAllocateBlock(size_t size)
  25. {
  26.     OSErr err;
  27.     
  28.     FW_PlatformHandle handle = ::TempNewHandle(size, &err);
  29.     if (err == noErr)
  30.     {
  31.         ::HLock(handle);
  32.         if (MemError() == noErr)
  33.         {
  34.             return *handle;
  35.         }
  36.     }
  37.     
  38.     return 0;
  39. }
  40.  
  41. //----------------------------------------------------------------------------------------
  42. // PlatformFreeBlock
  43. //----------------------------------------------------------------------------------------
  44.  
  45. void PlatformFreeBlock(void *ptr)
  46. {
  47.     FW_PlatformHandle handle = ::RecoverHandle((Ptr) ptr);
  48.     if (handle)
  49.     {
  50.         ::HUnlock(handle);
  51.         if (MemError() == noErr)
  52.             DisposeHandle(handle);
  53.     }
  54. }
  55.