home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c160 / 1.ddi / SOURCE / U4HUGE_A.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-22  |  1.0 KB  |  62 lines

  1.  
  2. /* u4huge_a.c  Huge Memory Allocation
  3.    (c)Copyright Sequiter Software Inc., 1987-1990.  All rights reserved.
  4. */
  5.  
  6. #include "p4misc.h"
  7. #include "d4all.h"
  8. #include "u4error.h"
  9.  
  10. #ifdef NO_HUGE
  11. #include <stdlib.h>
  12. #else
  13. #ifdef TURBO
  14. #include <dos.h>
  15. #include <alloc.h>
  16. #else
  17. #include <malloc.h>
  18. #endif
  19. #endif
  20.  
  21.  
  22. #ifdef IS_386
  23. #define MAX_ALLOC 0x7FFFFFFFL
  24. #else
  25. #ifdef NO_HUGE
  26. #define MAX_ALLOC  0xFFE0
  27. #endif
  28. #endif
  29.  
  30.  
  31. void H_PTR  u4huge_alloc( long num )
  32. {
  33.    #ifdef NO_HUGE
  34.       if ( num > MAX_ALLOC )
  35.      return( (void H_PTR) 0 ) ;
  36.  
  37.       return( h4alloc_try( (int) num) ) ;
  38.    #else
  39.       #ifdef TURBO
  40.      if ( num >= 700000L )
  41.         return( (void H_PTR) 0 ) ;
  42.      return( (void H_PTR) farmalloc((unsigned long) num) ) ;
  43.       #else
  44.      return( halloc( num, 1 ) ) ;
  45.       #endif
  46.    #endif
  47. }
  48.  
  49.  
  50. void u4huge_free( void H_PTR ptr )
  51. {
  52.    #ifdef NO_HUGE
  53.       h4free_memory( ptr ) ;
  54.    #else
  55.       #ifdef TURBO
  56.      farfree( (void far *) ptr ) ;
  57.       #else
  58.      hfree(ptr) ;
  59.       #endif
  60.    #endif
  61. }
  62.