--- os2sdk/demos/examples/suballoc/suballoc.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/suballoc/suballoc.c 2018/08/09 12:26:14 1.1.1.2 @@ -1,5 +1,5 @@ -/* This example illustrates the use of the following 286DOS functions: - * DOSSUBSET, DOSSUBALLOC, DOSSUBFREE +/* This example illustrates the use of the following MS OS/2 functions: + * DosSubSet, DosSubAlloc, DosSubFree * * This example allocates a segment , and initialises it for * suballocation. It suballocates a block from , and writes @@ -13,17 +13,19 @@ * * Compile as: cl -AL -G0 -Lp suballoc.c * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include /* CP/DOS function declarations */ -#include /* FP_OFF and FP_SEG macros */ +#define INCL_DOSMEMMGR -/* definitions used in DOSALLOCSEG call */ +#include /* SELECTOROF and OFFSETOF macros */ +#include /* MS OS/2 function declarations */ + +/* definitions used in DosAllocSeg call */ #define SIZEA 16000 /* bytes to allocate */ #define PRIVATE 0 /* segment will not be shared */ -/* definitions used in DOSSUBSET call */ +/* definitions used in DosSubSet call */ #define INIT 1 /* initialise size of subset in a segment*/ #define INCRSIZE 0 /* increase size of subset in a segment */ @@ -35,33 +37,33 @@ main () { - unsigned Selector, /* selector for segment allocated */ - BlockOffset, /* offset to block in segment subset */ + SEL Selector; /* selector for segment allocated */ + USHORT BlockOffset, /* offset to block in segment subset */ *addr; /*32 bit address to a word in segment*/ - DOSALLOCSEG (SIZEA, &Selector, PRIVATE); /* allocate a segment */ + DosAllocSeg (SIZEA, &Selector, PRIVATE); /* allocate a segment */ /* subset the segment to size SUBSIZEA ( must be =< SIZEA ) */ - DOSSUBSET (Selector, INIT, SUBSIZEA); + DosSubSet (Selector, INIT, SUBSIZEA); - DOSSUBALLOC(Selector, &BlockOffset, BLKSIZE); /* suballocate block B */ + DosSubAlloc(Selector, &BlockOffset, BLKSIZE); /* suballocate block B */ /* write VALUEA in to first word in block B of the subset */ - FP_SEG(addr) = Selector; - FP_OFF(addr) = BlockOffset; + SELECTOROF(addr) = Selector; + OFFSETOF(addr) = BlockOffset; *addr = VALUEA; - DOSREALLOCSEG (SIZER, Selector); /* grow the segment to size SIZER */ + DosReallocSeg (SIZER, Selector); /* grow the segment to size SIZER */ /* subset the segment to size SUBSIZEB where, * (SUBSIZEB > SUBSIZEA) and (SUBSIZEB =< SIZER) */ - DOSSUBSET(Selector, INCRSIZE, SUBSIZEB); + DosSubSet(Selector, INCRSIZE, SUBSIZEB); /* first word in block B should still contain VALUEA */ if (*addr != VALUEA) printf ("*** error: unexpected value in suballocated block ***\n"); - DOSSUBFREE (Selector, BlockOffset, BLKSIZE); /* free block B */ + DosSubFree (Selector, BlockOffset, BLKSIZE); /* free block B */ - DOSFREESEG (Selector); /* free the segment */ + DosFreeSeg (Selector); /* free the segment */ }