◄Up► ◄Contents► ◄Index► ◄Back► ──────────────────────────────────────────────────────────────────────────── /* 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 ); }