home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!charnel!sifon!newsflash.concordia.ca!mizar.cc.umanitoba.ca!raskin
- From: raskin@ccu.umanitoba.ca (Alan Raskin)
- Newsgroups: comp.lang.c
- Subject: Re: HALLOC and HUGE ptrs in Microsoft C
- Message-ID: <C1BFs8.6EF@ccu.umanitoba.ca>
- Date: 23 Jan 93 16:43:20 GMT
- References: <1993Jan21.175608.4279@arizona.edu>
- Sender: news@ccu.umanitoba.ca
- Distribution: world,local
- Organization: University of Manitoba, Winnipeg, Canada
- Lines: 43
- Nntp-Posting-Host: ccu.umanitoba.ca
-
- In <1993Jan21.175608.4279@arizona.edu> jjr@ace.ece.arizona.edu (Jeffrey J. Rodriguez) writes:
-
- >On a 486 running DOS, I need to allocate an array that's bigger than 64K,
- >fill it up with data, and write it to a binary file.
- >The MSC 7.0 manual says to use halloc(), which returns a "huge ptr".
- >It also says that huge ptrs cannot be passed as args to library functions.
- >Therefore, I can't pass the array to fwrite()!
- >So, how do I write the data? (Do I really have to loop through putchar?)
-
- Actually, I think that fwrite is one of the library routines that *will*
- take huge pointers; according to an old QuickC manual, "a huge array can
- be passed without difficulty to any of these [bsearch, fread, fwrite, halloc,
- hfree, lfind, lsearch, mem* and qsort] functions in a compact-, large-, or
- huge-model program."
-
- >This sure seems cumbersome.
- >It also seems that a program written for PC-DOS using halloc and huge
- >ptrs would not run on a Sun running UNIX.
- >So much for portable C.
-
- Because of the <expletive deleted> segmented-memory architecture of the Intel
- 80x86 CPUs, which at times requires the use of the non-portable "near", "far"
- and "huge" keywords, the only way to write "portable" C would be to use
-
- #if defined ( MSDOS ) /* M_I86 is also defined by MSC; what about Borland? */
- .
- . halloc(...);
- .
- #else
- .
- . malloc(...);
- .
- #endif
-
- at the appropriate places in your file.
-
- *SIGH*
-
- >Jeff Rodriguez
- >rodriguez@ece.arizona.edu
-
- Alan Raskin
- raskin@ccu.umanitoba.ca
-