[comp.lang.c] Is there a way to use extended memory easily from C

bbesler@vela.acs.oakland.edu (Brent Besler) (02/22/90)

I have a 386 PC which I am learning to program in C on.  Many of the applications
which I would like to program can easily use more 640K of data space.  Is there
any way to utilitze extended memory or EMS memory from Turbo C or Microsoft
quick C?
                                     Brent H. besler

bright@Data-IO.COM (Walter Bright) (03/08/90)

In article <151@vela.acs.oakland.edu> bbesler@vela.acs.oakland.edu (Brent Besler) writes:
<Is there
<any way to utilitze extended memory or EMS memory from Turbo C or Microsoft
<quick C?

In Zortech C/C++, there is a special pointer type called a handle pointer.
A pointer of this type is declared as:
	char __handle *h;
When allocating memory, instead of calling malloc, use:
	h = handle_malloc(size);
The syntax for using h is the same as for regular pointers, i.e. you can
do things like:
	*h = 'c';
	h[15] = 7;
	strcpy(h,p);
etc. The implementation of the handle pointers is such that they actually
allocate and refer to data in EMS. If no EMS is present in the execution
environment, then they behave like regular far pointers.

As far as I know, this facility is not available in any other DOS C compiler.

Standard disclaimer: I wrote it. I get paid for it. :-)