Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <dos.h>
    unsigned _dos_allocmem( unsigned size,
                            unsigned short *segment);

Description:
    The _dos_allocmem function uses system call 0x48 to allocate size
    paragraphs directly from DOS.  The size of a paragraph is 16 bytes.  The
    allocated memory is always paragraph aligned.  The segment descriptor
    for the allocated memory is returned in the word pointed to by segment.
     If the allocation request fails, the maximum number of paragraphs that
    can be allocated is returned in this word instead.

Returns:
    The _dos_allocmem function returns zero if successful.  Otherwise, it
    returns an MS-DOS error code and sets  errno to  ENOMEM indicating
    insufficient memory or corrupted memory.

See Also:
    alloca, calloc Functions, _dos_freemem, _dos_setblock, halloc, malloc Functions

Example:
    #include <stdio.h>
    #include <dos.h>

    void main()
      {
        unsigned short segment;

        /* Try to allocate 100 paragraphs, then free them */
        if( _dos_allocmem( 100, &segment ) != 0 ) {
          printf( "_dos_allocmem failed\n" );
          printf( "Only %u paragraphs available\n",
                   segment );
        } else {
          printf( "_dos_allocmem succeeded\n" );
          if( _dos_freemem( segment ) != 0 ) {
            printf( "_dos_freemem failed\n" );
          } else {
            printf( "_dos_freemem succeeded\n" );
          }
        }
      }

Classification:
    DOS

Systems:
    DOS, OS/2 1.x(all), OS/2 2.x, NT, DOS/PM

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