_halloc

Description

Allocates a huge memory block.

#include <malloc.h> Required only for function declarations  

void __huge *_halloc( long num,size_t size );

num Number of elements  
size Length in bytes of each element  

Remarks

The _halloc function allocates a huge array from the operating system consisting of num elements, each of which is size bytes long. Each element is initialized to 0. If the size of the array is greater than 128K (131,072 bytes), the size of an array element must then be a power of 2.

Use the _hfree function to deallocate a block of memory returned by halloc.

Return Value

The _halloc function returns a void huge pointer to the allocated space, which is guaranteed to be suitably aligned for storage of any type of object. To get a pointer to a type other than void huge, use a type cast on the return value. If the request cannot be satisfied, the return value is NULL.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

See Also

calloc functions, free functions, _hfree, malloc functions

Example

/* HALLOC.C: This program uses _halloc to allocate space for 30,000 long

* integers, then uses _hfree to deallocate the memory.

*/

#include <stdio.h>

#include <stdlib.h>

#include <malloc.h>

void main( void )

{

long __huge *hbuf;

/* Allocate huge buffer */

hbuf = (long __huge *)_halloc( 30000L, sizeof( long ) );

if ( hbuf == NULL )

printf( "Insufficient memory available\n" );

else

printf( "Memory successfully allocated\n" );

/* Free huge buffer */

_hfree( hbuf );

}

Output

Memory successfully allocated