Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>halloc() allocate and zero huge memory block</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
halloc()                 Allocate and Zero Huge Memory Block

 #include   <malloc.h>                   Required for declarations only

 char       huge *halloc(n,size);
 long       n;                           Number of elements to allocate
 unsigned   size;                        Number of bytes in each element

    halloc() allocates space for a HUGE array of 'n' elements, each of
    'size' bytes. All elements are initialized to zero.  If the total
    size to be allocated (n*size) is greater than 128K, then 'size' must
    be a power of 2.

    Returns:    A char huge pointer to the allocated space.  Returns NULL
                (defined in <stdio.h>) if the space cannot be allocated.

      Notes:    The returned space is guaranteed to be properly aligned
                for any type of object.  Use a type cast if you a need a
                pointer to a type other than char huge.

  -------------------------------- Example ---------------------------------

    The following statements allocate space for 50000 long integers and
    then free the allocated space.

           #include <malloc.h>
           #include <stdio.h>      /* for printf and NULL */

           long huge *huge_memptr;

           main()
           {
               if ((huge_memptr = (long huge *) halloc(50000L, sizeof(long)))
                        == NULL)
                    printf("not enough memory for array\n");
               else {
                    .
                    .
                    hfree(huge_memptr);
                }
           }

See Also: hfree() malloc() calloc() realloc()

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