1.9 Using Huge Arrays with Library Functions

In programs that use small, compact, medium, and large memory models, the compiler allows you to use arrays exceeding the 64K (kilobyte) limit of physical memory in these models by explicitly declaring the arrays as __huge. However, generally, you cannot pass huge pointers as arguments to run-time library functions. In the compact-model library used by compact-model programs and in the large-model library used by both large-model and huge-model programs, only the functions listed below use pointer arithmetic that works with huge items:

bsearchfreadfwrite_fmemccpy_fmemchr_fmemcmp_fmemcpy_fmemicmp_fmemmove_fmemset_halloc_hfree_lfind_lsearch_memccpymemchrmemcmpmemcpy_memicmpmemmovememsetqsort

With this set of functions, you can read from, write to, search, sort, copy, initialize, compare, or dynamically allocate and free huge arrays; the huge array can be passed without difficulty to any of these functions in a compact-, large-, or huge-model program. The model-independent routines in the above list (those beginning with _f) are available in all memory models.

The memset, memcpy, and memcmp library routines are available in two versions: as C functions and as intrinsic (inline) code. The function versions of these routines support huge pointers in compact and large memory models, but the intrinsic versions do not support huge pointers. (The function version of such routines generates a call to a library function, whereas the intrinsic version inserts inline code into your program. For information on how to select the intrinsic versions of library routines, see the /Oi option in Chapter 13 of Environment and Tools (in the Microsoft C/C++ version 7.0 documentation set) or consult your compiler documentation.)