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_alloc http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                                dos_alloc

   Usage
   include <dos.h>
   unsigned dos_alloc(unsigned para);

   Description
   Allocates memory from the heap by a direct call to MSDOS. The argument
   para contains the number of  paragraphs required. Use:
   bytes_required/16
   Memory allocated with dos_alloc should be freed using dos_free only.

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

   unsigned newseg;

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

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

   Return Value
   If  successful dos_alloc returns the segment of the  allocated  block,
   otherwise  zero  is  returned and _doserrno is set to  the  DOS  error
   number.


See Also: DOS_Package dos_calloc dos_free dos_setblock

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