home *** CD-ROM | disk | FTP | other *** search
/ Kyūkyoku!! X68000 Emulator / X68000Book.dat / mac / OLS / X68000 / Ko-Window / kow142s.lzh / corlib / WindowHeapAlloc.c < prev    next >
C/C++ Source or Header  |  1995-02-19  |  786b  |  48 lines

  1. /*    1995 H.Ogasawara (COR.)    */
  2.  
  3. #include    <sys_doslib.h>
  4. #include    <wlib.h>
  5.  
  6. extern int    WindowProcessID;
  7. extern int    WindowHeapSize;
  8. extern void    _HeapInit();
  9.  
  10. #ifdef XC
  11. extern char    *_BEND,
  12.         *_HSTA,
  13.         *_HEND;
  14. #endif
  15. #ifdef LIBC
  16. extern char    *_esta,
  17.         *_HSTA,
  18.         *_HEND;
  19. # define    _BEND    _esta
  20. #endif
  21.  
  22.  
  23. int
  24. KoWindowHeapAlloc()
  25. {
  26.     ProcessInfo    *pp= WindowGetProcessInfo( WindowProcessID );
  27.     char        *heap;
  28.     if( pp->HeapSize > 0 ){
  29.         MFREE( pp->Heap );
  30.         pp->HeapSize= 0;
  31.     }
  32.     if( WindowHeapSize > 0 ){
  33.         heap= MALLOC( WindowHeapSize );
  34.         if( heap > (char*)0x1000000 )
  35.             return    FALSE;
  36.         _HSTA= heap;
  37.         _HEND= _HSTA+ WindowHeapSize;
  38. #ifdef XC
  39.         _HeapInit();
  40. #endif
  41.         pp->Heap= heap;
  42.     }else
  43.         _HEND= _HSTA;
  44.     pp->HeapSize= WindowHeapSize;
  45.     return    TRUE;
  46. }
  47.  
  48.