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_alloc</b> 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 MS-DOS. The argument
   para contains the number of paragraphs required. Use:

           (bytes_required+15)/16

   Memory allocated with dos_alloc should be freed using dos_free only.

Example 

   #include <dos.h>

   #include <stdio.h>
   #include <stdlib.h>

   unsigned newseg;

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

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

           printf("Memory freed successfully\n");
       return EXIT_SUCCESS;
   }


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



See Also: dos_calloc dos_free dos_setblock

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