🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #7855

Re: Help needed with Dynamic Memory Allocation

#7855
From: Robert Sandilands
Date: Thu, 14 Dec 1995 07:10
46 lines
2257 bytes
-----BEGIN PGP SIGNED MESSAGE-----

Matt Arnold (marnold@netcom.com) wrote:
: forster@liverpool.ac.uk (Mr R. Forster) writes:

: >I have posted this recently in the group comp.lang.c,

: >I need a algorithm to find the quickest way to establish the maximum amount
: >of dynamic memory that can be allocated using C.

: >Using DOS and the function MALLOC.

A better way to do it would be:

unsigned long MemAvail()
// Assuming Borlandc but it should be available in other compilers
{
 REGS r;
 r.h.ah=0x48;
 r.x.bx=0xffff;  // Try and allocate 1MB or RAM - it will fail
 int86( 0x21, &r, &r ); // Call DOS
 return( r.x.bx ); // This call failed and it returns to max mem avail in BX 
}

Hope this helps. It should be easier and faster to implement. Under 
borlandc there is the commands coreleft and farcoreleft which does the same
type thing.
- --
_________________________________________________________________________
This is my views, and mine alone. I do not presume to speak for anybody
but me, myself and my shadow.
- -------------------------------------------------------------------------
         Robert Sandilands - a nutty engineer and bug squisher.
       	    Virus Analist : CSIR Virus Protection Services
 Tel: +27-12-841-2106, Fax: +27-12-841-3307, Email: robert@vps.cis.co.za
- -------------------------------------------------------------------------

-----BEGIN PGP SIGNATURE-----
Version: 2.6

iQCVAgUBMM/N8IWe5NcbXFk5AQGQ3gP+Pzl4yPO3ELrdH0kXGcY41x8pEhq9UahA
HBwjMtAbYh47lQsdNEFl3dU9dbna3EaT2AgqioWldHtYqwulMtIOHAnMWZjJIvzo
vCNhqj5h0Lx1iTXVicyHmpBEifaWuRX1iqNLaUUlTo0k9hIBDAHBh7XBl8xzBy7g
2BVBNce29W0=
=X3DF
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <4aoikj$4o4@africa.cis.co.za>
Path: arc1-ca.pugleaf.net!vps.cis.co.za!robert
References: <DJEzpt.A7M@liverpool.ac.uk> <marnoldDJF56n.6AE@netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!vps.cis.co.za!robert
From: robert@cis.co.za (Robert Sandilands)
Newsgroups: comp.os.msdos.programmer,comp.lang.c++
Subject: Re: Help needed with Dynamic Memory Allocation
Followup-To: comp.os.msdos.programmer,comp.lang.c++
Date: 14 Dec 1995 07:10:11 GMT
Organization: CSIR Virus Protections Systems
Distribution: world
Message-ID: <4aoikj$4o4@africa.cis.co.za>
References: <DJEzpt.A7M@liverpool.ac.uk> <marnoldDJF56n.6AE@netcom.com>
Reply-To: robert@vps.cis.co.za
NNTP-Posting-Host: 196.2.16.53
X-Newsreader: TIN [version 1.2 PL2]