From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: DPMI ??? Date: Tue, 24 Feb 1998 18:41:49 -0500 Organization: Two pounds of chaos and a pinch of salt. Lines: 44 Message-ID: <34F35ABD.46DD@cs.com> References: <6cs9f6$2vo AT news DOT euro DOT net> NNTP-Posting-Host: ppp207.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Pieter van Ginkel wrote: > > I'm deseret for using the dpmi functions in my new program, but I can't find > a example of how to do it. I've tried it a little myself, but then I tried > it, I got a SIGSEGV, so I've probably done something wrong. Could someone > give me a simple (or more suphisticated) program that I can use to learn how > to use dpmi. I was thinking of something like this: You do not need to use the DPMI functions for general memory allocation. The DPMI host handles all such requests completely transparently; you can go ahead and malloc( 1024 * 1024 ) or anything else your heart desires. The only time the DPMI functions are required are when you want to use operating system services that are not directly representable in C. You need to get your head out of the 16-bit gutter and realize the freedom of the protected mode environment. :-) > void main( void ) > { > char * dummy = malloc( 81 ); > strcpy( dummy, "Hello world!" ); > cprintf( dummy ); > free( dummy ); > } This code is perfectly fine, except that void is not a legal return type for main(). The operating system expects main() to return an integer, and you should also provide a return statement. > But than with use of __dpmi_allocate_memory and other routines. If you have > something that uses this way of allocating memory, but it's not at oll like > this, also please send it to me. There is no need to use the __dpmi_allocate_memory() sledgehammer on a fly that can be swatted perfectly well with standard library functions. -- --------------------------------------------------------------------- | John M. Aldrich | "If 'everybody knows' such-and-such, | | aka Fighteer I | then it ain't so, by at least ten | | mailto:fighteer AT cs DOT com | thousand to one." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------