home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20116 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  1.9 KB

  1. Path: sparky!uunet!olivea!charnel!sifon!newsflash.concordia.ca!mizar.cc.umanitoba.ca!raskin
  2. From: raskin@ccu.umanitoba.ca (Alan Raskin)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HALLOC and HUGE ptrs in Microsoft C
  5. Message-ID: <C1BFs8.6EF@ccu.umanitoba.ca>
  6. Date: 23 Jan 93 16:43:20 GMT
  7. References: <1993Jan21.175608.4279@arizona.edu>
  8. Sender: news@ccu.umanitoba.ca
  9. Distribution: world,local
  10. Organization: University of Manitoba, Winnipeg, Canada
  11. Lines: 43
  12. Nntp-Posting-Host: ccu.umanitoba.ca
  13.  
  14. In <1993Jan21.175608.4279@arizona.edu> jjr@ace.ece.arizona.edu (Jeffrey J. Rodriguez) writes:
  15.  
  16. >On a 486 running DOS, I need to allocate an array that's bigger than 64K,
  17. >fill it up with data, and write it to a binary file.
  18. >The MSC 7.0 manual says to use halloc(), which returns a "huge ptr".
  19. >It also says that huge ptrs cannot be passed as args to library functions.
  20. >Therefore, I can't pass the array to fwrite()!
  21. >So, how do I write the data? (Do I really have to loop through putchar?)
  22.  
  23. Actually, I think that fwrite is one of the library routines that *will*
  24. take huge pointers; according to an old QuickC manual, "a huge array can
  25. be passed without difficulty to any of these [bsearch, fread, fwrite, halloc,
  26. hfree, lfind, lsearch, mem* and qsort] functions in a compact-, large-, or
  27. huge-model program."
  28.  
  29. >This sure seems cumbersome.
  30. >It also seems that a program written for PC-DOS using halloc and huge
  31. >ptrs would not run on a Sun running UNIX.
  32. >So much for portable C.
  33.  
  34. Because of the <expletive deleted> segmented-memory architecture of the Intel 
  35. 80x86 CPUs, which at times requires the use of the non-portable "near", "far" 
  36. and "huge" keywords, the only way to write "portable" C would be to use 
  37.  
  38. #if defined ( MSDOS )  /* M_I86 is also defined by MSC; what about Borland? */
  39. .
  40. .    halloc(...);
  41. .
  42. #else
  43. .
  44. .    malloc(...);
  45. .
  46. #endif
  47.  
  48. at the appropriate places in your file. 
  49.  
  50. *SIGH*
  51.  
  52. >Jeff Rodriguez
  53. >rodriguez@ece.arizona.edu
  54.  
  55. Alan Raskin
  56. raskin@ccu.umanitoba.ca
  57.