From: "Campbell, Rolf [SKY:1U32:EXCH]" Newsgroups: comp.os.msdos.djgpp Subject: Re: malloc() and CWSDPMI 4.0 Date: Wed, 14 Jul 1999 12:06:42 -0400 Organization: Nortel Networks Lines: 46 Message-ID: <378CB591.82CC6753@americasm01.nt.com> References: <378bbab9 DOT 22414525 AT news DOT uni-wuppertal DOT de> NNTP-Posting-Host: bmerhc00.ca.nortel.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Mailer: Mozilla 4.6 [en] (X11; I; HP-UX B.10.20 9000/712) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id NAB14058 Reply-To: djgpp AT delorie DOT com Winfried Salomon wrote: > Hello people, > I am a beginner with GNU-compilers and with C and I have a problem > with malloc(), the compiler is GNU C 2.81 under Win98. My program > should test the XMS-memory under DOS 7.10, so I got CWSDPMI 4.0 to > allocate up to 256 MB XMS-Ram. > > There are 2 problems: First I donīt find a function to get the > greatest *physical* coherent memory block, so I use malloc() with the > method of successive approximation, to find the biggest amount by > testing if the returned pointer is valid or not. So far so bad, the > second problem: With 96 MB Ram I allocate 128 MB + 4 KB blocksize! How > can this be? > > I also wonder that I can run malloc() without CWSDPMI, but only with > 64 MB + 4 KB maximum blocksize. How can I allocate precise the > availible XMS-Ram? > > An adjacent question is, how could I combine GNU Fortran77 0523 with > GNU C 2.81, because I have source in Fortran from another machine. The > disadvantage of GNU Fortran is the bad dokumentation and the problems > with hardware access, there is no malloc() or such thing. Well, first of all, DJGPP doesn't use XMS memory. It runs in 32-bit protected mode, which means it just uses memory. (AFAIK XMS has no meaning in 32-bit mode). This also means that you don't need an XMS manager. Also, CWSDPMI uses virtual memory which allows it to simulate extra memory using your hard-disk. #include int __dpmi_get_memory_information(__dpmi_memory_info *_buffer); You can use this function to find the largest allocatable block of memory. But this will not include memory that has already been allocated and free'd by your program. BTW, why do you need to know how much is available? Most programs need a certain, fixed amount. -- -Rolf Campbell (39)3-6318