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

 #include   <malloc.h>

 void       near *_nmalloc(size);
 size_t     size;                        Number of bytes to allocate

    _nmalloc() allocates a block of 'size' bytes in the default data
    segment. (In small-model and medium-model programs, malloc() maps to
    _nmalloc().)

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

      Notes:    Use _nfree() to deallocate block allocated with
                _nmalloc().

 Portability:   Applies to MS DOS only.

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

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

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

           char near *near_memptr;

           main()
           {
               if ((near_memptr = _nmalloc(1000)) == NULL)
                    printf("not enough room to allocate memory\n");
               else {
                    .
                    .
                    .
                    _nfree(near_memptr);
                }
           }


See Also: _nfree() _nmsize() malloc() _fmalloc()

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