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>_fmalloc() allocate far memory block</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_fmalloc()               Allocate Far Memory Block

 #include   <malloc.h>                   Required for declarations only

 char       far *_fmalloc(size);
 unsigned   size;                        Number of bytes to allocate

    _fmalloc() allocates a block of 'size' bytes outside the default data
    segment.  If the block can't be allocated outside the default data
    segment, then the allocation will be retried in the default data
    segment.

    Returns:    Pointer to allocated space.  Returns NULL (defined in
                <stdio.h>) if the space cannot be allocated.

      Notes:    The storage space pointed to on return of _fmalloc() is
                guaranteed to be properly aligned for storage of any type
                of object. Use a type cast to get a pointer to a type
                other than char.

                Use _ffree() to deallocate blocks allocated with
                _fmalloc().

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

    The following statements allocate space for 1000 bytes outside the
    default data segment and then free the allocated space.

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

           char far *far_memptr;

           main()
           {
               if ((far_memptr = _fmalloc(1000)) == NULL)
                    printf("not enough room to allocate memory\n");
               else {
                    .
                    .
                    _ffree(far_memptr);
                }
            }

See Also: _ffree() _fmsize() malloc() _nmalloc()

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