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 6.0 - <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

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

    halloc() allocates space for a huge array consisting of 'n' elements,
    initialized to 0, of 'size' bytes each.  'size' must be a power of 2
    if the total size to be allocated (n*size) is greater than 128K.

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

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

 Portability:   Applies to MS DOS only.

   -------------------------------- 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