home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
-
- char far *Alloc( long );
- void Nomem( void );
-
- char far *Alloc ( x ) /* allocate x bytes of far memory */
- long x;
- {
- union REGS regs;
-
- regs.h.ah = 0x48; /* allocate memory dos call */
- x = (x+15)>>4; /* get number of paragraphs to allocate */
- regs.x.bx = (int)x;
- intdos( ®s, ®s ); /* call dos; request memory */
- if (regs.x.cflag) /* memory allocation error */
- Nomem();
- return( (char far *)((long)regs.x.ax<<16) ); /* make a far pointer */
- }
-
- void Nomem () { /* a memory allocation request has failed */
- fprintf( stderr, "out of memory\n" );
- exit( -1 );
- }
-