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

 void       far *_fmalloc(size);
 size_t     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:    Far 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
                always properly aligned for storage of any type of
                object. Use a type cast to get a pointer to a type other
                than void.

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

 Portability:   Applies to MS DOS only.

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