Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Blinker 5.10 Online Reference - <b> dosallochuge()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 DosAllocHuge()
------------------------------------------------------------------------------
 Purpose:
 Allocate an extended memory block of up to 16 Mb.

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

 Parameters:
 segcount  Count of full 64 Kb 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 64 Kb 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.

 Returns:
 The base selector of the huge block.

 Description:
 DosAllocHuge() allocates a memory block of up to 16 Mb and returns a
 selector that points to the base of the block. When the block is larger
 than 64 Kb 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 64 Kb 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
 initial allocation size, so preventing the block from being reallocated
 beyond (segcount+1) 64 Kb 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()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson