--- os2sdk/demos/examples/huge/huge.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/huge/huge.c 2018/08/09 12:26:08 1.1.1.2 @@ -1,7 +1,7 @@ /* This example illustrates allocating a huge segment, addressing * the segment, growing & shrinking the segment and freeing the - * segment. The following 286DOS functions are illustrated here: - * DOSALLOCHUGE, DOSREALLOCHUGE, DOSFREESEG + * segment. The following MS OS/2 functions are illustrated here: + * DosAllocHuge, DosReAllocHuge, DosFreeSeg * * This example allocates a huge segment. It writes a value to one of the * words in the huge segment. It grows the segment and then shrinks the @@ -11,13 +11,15 @@ * how to manage and access huge segments - it doesn't perform any useful * function. * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include /* contains CP/DOS function declarations */ -#include /* contains FP_SEG and FP_OFF macros */ +#define INCL_DOSMEMMGR -/* used in DOSALLOCHUGE call */ +#include /* contains SELECTOROF and OFFSETOF macros */ +#include /* contains MS OS/2 function declarations */ + +/* used in DosAllocHuge call */ #define NUMSEGA 3 /* number of segments in huge segment */ #define SIZEA 8000 /* number of bytes in last segment */ #define PRIVATE 0 /* huge segment will not be shared */ @@ -25,32 +27,32 @@ #define WORDA 35000 /* a word in segment 2 in huge segment */ #define VALUEA 15 /* value to write into WORDA */ -/* used in DOSREALLOCHUGE call (growing the segment) */ +/* used in DosReAllocHuge call (growing the segment) */ #define NUMSEGR 5 /* number of segments in huge segment */ #define SIZER 12000 /* number of bytes in last segment */ main () { - unsigned FirstSelector; /* first selector for huge segment */ + SEL FirstSelector; /* first selector for huge segment */ int /*huge*/ *HugeSeg; /* pointer to a huge segment */ /* allocate a huge segment */ - DOSALLOCHUGE (NUMSEGA, SIZEA, &FirstSelector, MAXSEGS, PRIVATE); + DosAllocHuge (NUMSEGA, SIZEA, &FirstSelector, MAXSEGS, PRIVATE); /* compute the address to the huge segment */ - FP_SEG(HugeSeg) = FirstSelector; - FP_OFF(HugeSeg) = 0; + SELECTOROF(HugeSeg) = FirstSelector; + OFFSETOF(HugeSeg) = 0; HugeSeg[WORDA] = VALUEA; /* grow the huge segment */ - DOSREALLOCHUGE (NUMSEGR, SIZER, FirstSelector); + DosReallocHuge (NUMSEGR, SIZER, FirstSelector); /* shrink the huge segment to its orginal size */ - DOSREALLOCHUGE (NUMSEGA, SIZEA, FirstSelector); + DosReallocHuge (NUMSEGA, SIZEA, FirstSelector); /* WORDA should still contain VALUEA */ if (HugeSeg[WORDA] != VALUEA) printf ("*** error: unexpected value in huge segment ***\n"); - DOSFREESEG (FirstSelector); /* free the huge segment */ + DosFreeSeg (FirstSelector); /* free the huge segment */ }