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

 Function : Allocate an extended memory block of up to 64 Kb.

 Syntax   : USHORT BLXAPI DosAllocSeg(USHORT size, PSEL selector,
            USHORT flags);

 size       Size of block in bytes (max=64kb).

 selector   Pointer to an integer to receive the selector.

 flags      Reserved (must be 0).

 Return   : Selector for the extended memory block.

 DosAllocSeg() allocates a memory block up to 64kb in size.

 Most high level languages provide a memory allocation function equivalent to
 this function, such as malloc() in C. These functions can be used instead of
 DosAllocSeg() to manage blocks of memory less than 64kb in size,
 particularly when minimum source code differences between real and protected
 mode are required.

 Use DosMemAvail() to find the amount of available memory that can be
 allocated using DosAllocSeg().

 Example :

    #include <stdlib.h>
    #include <stdio.h>
    #include <string.h>
    #include <blx286.h>
    void main(void)
    {
    SEL         selector;
    /* Allocate a 4KB block */
    if (DosAllocSeg(4096, &selector, 0) != 0)
       {
       printf("DosAllocSeg() failed\n");
       exit(255);
       }
    printf("4K block allocated at : %04X\n",selector);
    /* 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