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_setblock( unsigned size,
                            unsigned short segment,
                            unsigned *maxsize );

Description:
    The _dos_setblock function uses system call 0x4A to change the size of
    segment, which was previously allocated by  _dos_allocmem, to size
    paragraphs.  If the request fails, the maximum number of paragraphs that
    this memory block can be changed to is returned in the word pointed to
    by maxsize.

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

See Also:
    _dos_allocmem, _dos_freemem, realloc Functions

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

    void main()
      {
        unsigned short segment;
        unsigned maxsize;

        /* 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" );
          /* Try to increase it to 200 paragraphs */
          if( _dos_setblock( 200, segment, &maxsize ) != 0 ){
            printf( "Unable to increase the size\n" );
          }
          if( _dos_freemem( segment ) != 0 ) {
            printf( "_dos_freemem failed\n" );
          }
        }
      }

Classification:
    DOS

Systems:
    DOS, DOS/PM

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