C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
HALLOC.C
                                             Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
/* HALLOC.C illustrates dynamic allocation of huge memory using functions:
 *      _halloc          _hfree
 */
 
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
 
void main()
{
    char __huge *bigbuf, __huge *p;
    long count = 100000L;
 
    /* Allocate huge buffer (100,000 bytes). */
    bigbuf = (char __huge *)_halloc( count, sizeof( char ) );
    if( bigbuf == NULL )
    {
        printf( "Insufficient memory" );
        exit( 1 );
    }
 
    /* Fill the buffer with characters. */
    for( p = bigbuf; count; count--, p++ )
        *p = (char)(count % 10) + '0';
 
    /* Free huge buffer. */
    _hfree( bigbuf );
    exit( 0 );
}
                                    -♦-