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>_dos_setblock() change the size of a memory block</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _dos_setblock()         Change the size of a memory block

 #include   <dos.h>

  unsigned     _dos_setblock(size, segment, maxsize);
  unsigned size;    Segment size requested, in 16 byte paragraphs
  unsigned segment; Segment address of block to be modified
  unsigned *maxsize;     Buffer for return value indicating maximum size
                         available

    _dos_setblock() uses MS-DOS function call 4Ah to change the size of a
    memory block that was previously allocated by _dos_allocmem() to the
    value specified in 'size', expressed in 16-byte paragraphs. 'Segment'
    is the block address returned by _dos_allocmem(). If the request is
    unsuccessful, the maximum size available, in 16 byte paragraphs, is
    placed in the buffer that 'maxsize' points to.

    Returns:    If the memory was successfully allocated _dos_allocmem()
                returns 0. If unsuccessful it returns the MS-DOS error
                code and sets errno to ENOMEM. The MS-DOS error code will
                be one of the following:

                    07h = memory control blocks damaged
                    08h = insufficient memory to satisfy request
                    09h = memory block was not originally allocated with
                    48h, so cannot be accessed with function request 4Ah

      Notes:    In MS-DOS 3.0, or higher dosexterr() can be used for
                extended error code information.

   Portability:     MS-DOS only, version 2.0 or higher

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

 This program allocates 4k bytes of memory if available, or else it reports
 the maximum size block available.

           #include <dos.h>

           unsigned segment;
           unsigned *maxsize;

           main()
             {
                .
                .
              /* Allocate a 4k block of memory (256 paragraphs) */
              if (_dos_setblock(256, segment, maxsize))
                  /* unable to allocate block */
                  printf("Insufficient memory: only %lu bytes available\n",
                  (long) *maxsize * (long) 16);
              else
                  printf("4k bytes allocated\n");
                .
                .
             }


See Also: _dos_allocmem() _dos_freemem()

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