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++ 3.0r4 - <b>dos_setblock</b> 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 <dos.h>
   #include <stdio.h>
   #include <stdlib.h>

   int main()
   {
       unsigned newseg;

       if ((newseg = dos_alloc(10)) == 0)
           {
           printf("dos_alloc failed\n");
           exit(EXIT_FAILURE);
           }
       else

           {
           printf("Memory allocated successfully\n");
           }

       newseg = dos_setblock(20,newseg);

       if (_doserrno)
           {
           printf("dos_setblock failed: ");
           printf("only %ud available\n",newseg);
           exit(EXIT_FAILURE);
           }
       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



See Also: dos_alloc dos_calloc dos_free

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