home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LIBSRC.ZOO / libsrc / local / sod.c < prev    next >
Text File  |  1992-03-14  |  863b  |  41 lines

  1. #define INCL_DOSMEMMGR
  2. #define INCL_DOSERRORS
  3. #include <os2.h>
  4. #include <sys/types.h>
  5. #include <errno.h>
  6.  
  7. ULONG Dos32AllocMem() asm ("Dos32AllocMem");
  8.  
  9. void *__start_of_data = 0;
  10. void *__first_uncommited_block = 0;
  11. void *__first_uncommited_byte = 0;
  12.  
  13. void * start_of_data ()
  14. {
  15.    ULONG rc;
  16.  
  17.    if (__start_of_data)
  18.       return (__start_of_data);
  19.  
  20.     rc = Dos32AllocMem (&__start_of_data, 0x4000000, PAG_READ | PAG_WRITE);
  21.  
  22.     if (rc) {
  23.        if (rc == ERROR_NOT_ENOUGH_MEMORY) {
  24.           errno = ENOMEM;
  25.           return ((void *)-1);
  26.        }
  27.  
  28.        if (rc == ERROR_INVALID_PARAMETER) {
  29.           errno = EINVAL;
  30.           return ((void *)-1);
  31.        }
  32.  
  33.        errno = -1;
  34.        return ((void *)-1);
  35.     }
  36.  
  37.     __first_uncommited_block = __first_uncommited_byte = __start_of_data;
  38.     return (__start_of_data);
  39. }
  40.  
  41.