Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - dos_setblock http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                               dos_setblock

   Usage
   include <dos.h>
   unsigned dos_setblock(unsigned newsize, unsigned seg);

   Description
   Attempts  to  modify the size of a memory block  previously  allocated
   with  dos_alloc or dos_calloc. The newsize argument is the new  number
   of  paragraphs requested, seg is the segment address of the  allocated
   memory.

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

   main()
   {
   unsigned newseg;

        if((newseg = dos_alloc(10)) == 0)
        {
             printf("dos_alloc failed\n");
             exit(1);
        }
        else
             printf("Memory allocated successfully\n");

        newseg = dos_setblock(20);

        if(_doserrno)
        {
             printf("dos_setblock failed: only %ud available\n");
             exit(1);
        }
        else
             printf("Memory block successfully expanded\n");

        if(dos_free(newseg)== -1)
             printf("Unable to free memory\n");
        else
             printf("Memory freed successfully\n");
   }

   Return Value
   If successful the segment address of the allocated memory is returned,
   otherwise  _doserrno is set and the maximum size that the block  could
   be expanded to is returned, in which case the block is not altered.


See Also: DOS_Package dos_alloc dos_calloc dos_free

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