[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DosAllocHuge()                Allocate extended memory block of up to 16MB.
------------------------------------------------------------------------------

 Function : Allocate an extended memory block of up to 16MB.

 Syntax   : USHORT BLXAPI DosAllocHuge(USHORT segcount,
            USHORT lastsize, PSEL selector, USHORT segmax,
            USHORT flags);

 segcount   Count of full 64kb segments to allocate.

 lastsize   Size of the last segment in bytes (0-65535).

 selector   Pointer to an integer to receive the initial selector for the
            block.

 segmax     Maximum number of 64kb blocks which may later be allocated to the
            block in a call to DosReallocHuge(). (This can be 0, see below).

 flags      Reserved. Must be zero.

 Return   : The base selector of the huge block.

 DosAllocHuge() allocates a memory block of up to 16MB and returns a selector
 that points to the base of the block. When the block is larger than 64kb a
 contiguous block of selectors is allocated and one selector is assigned to
 each complete or partial segment. The increment used to move from one
 selector to the next is calculated using DosGetHugeShift().

 Segmax specifies the maximum number of 64kb blocks that the block can be
 resized to. Enough contiguous selectors are allocated by DosAllocHuge() to
 ensure subsequent reallocations will succeed. Specifying a segmax value of 0
 will cause DosAllocHuge() to compute a segmax value equal to the required
 inital allocation size, so preventing the block from being reallocated
 beyond (segcount+1) 64kb segments.

 Example:

    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <blx286.h>
    void main(void)
    {
    SEL         selector;
    USHORT      hshift ;
    int         selinc ;
    char        *fp;
    /* Allocate a 1MB block */
    if (DosAllocHuge(16,0,&selector,0,0) != 0)
       {
       printf("DosAllocHuge() failed\n");
       exit(255);
       }
    DosGetHugeShift(&hshift);
    selinc = 1 << hshift ;
    /* fill each 64kb block with NULLS */
    tmpsel = selector;
    for (cnt = 0, cnt <16; cnt++,tmpsel += selinc);
       {
       fp = MK_FP(tmpsel,0);
       *fp = 0;          /* Fill first character */
       fp++;                /* Advance to next character */
       memset(fp, 0, 0xFFFFh);
       printf("Cleared segment : %04X\n",tmpsel);
       }
    /* Free the block */
    DosFreeSeg(selector);
    }

See Also: DosFreeSeg()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson