🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: New and farcoreleft()

#1290
From: Stephen Groundwater
Date: Sat, 05 Sep 1992 03:45
52 lines
3247 bytes
In a previous article, wright@epx.cis.umn.edu (Mark Wright) says:

>In article <HOLLEN.92Sep3114500@peg.megatek.UUCP> hollen@megatek.UUCP (Dion Hollenbeck) writes:
>>In article <1992Sep3.134102.17553@news2.cis.umn.edu>
>>wright@epx.cis.umn.edu (Mark Wright) writes:
>>
>>Mark>      In a C++ program I've been writing, strategically placed
>>Mark>   farcoreleft()'s seem to be saying that my objects are not being
>>Mark>   de-allocated correctly when I 'destroy' them.  Should I worry about
>>Mark>   this, or is farcoreleft() designed for use with malloc()?  If so,
>>Mark>   is there a C++ function which will tell me how much mem. I have
>>Mark>   left?  I'm using Borland C++ v3.1.
>>
>>Yes it is designed for use with malloc().  It is probably working
>>correctly, you probably do not know how it is working.
>[...]
>>-- 
>>Dion Hollenbeck       UUCP: {uunet, ucsd, sun}!megatek!hollen
>>                      INTERNET:            hollen@megatek.com
>>Megatek Corporation  9645 Scranton Rd.  San Diego, Ca.  92121
>
>I don't think I stated my problem very clearly.  My concern is that allocating
>space with 'new' may confuse farcoreleft().  I know that combining C style 
>memory allocation routines (ie. malloc()) and C++ memory allocation routines
>(ie. new) will cause problems - I guess what I want to know is 'Is 
>farcorleft() C++ aware?'  Does farcoreleft() know about 'new', or is it
>specifically a C function.  And if so, is there a C++ version of farcoreleft()?
>
This problem does not occur, new is a function, just like any other, and
when it is called it uses the standard routines to get its memory. So
that:
buf=(char *)new char[100];
is functionally equivilent too, and is turned into eventually:
buf=(char *)malloc(100);
Well, you get the jist of it anyway. Your problem
is a non-problem. If you are really paranoid, you could define
a new
operator new () {}
for all your classes with your own memory allocation done there.

The thing that most concerns me is that you talk of malloc with farcoreleft
you better be sure you are using the large, compact or huge models there,
otherwise you should be using farmalloc (or equivilent in your compiler)
because otherwise you are allocating memory in the data segment, an area 
of memory that does not change size for farcoreleft, because the data 
segment is allocated when the program starts, and is dumped when the 
program stops, and doesn't change size when the program is running.
And the memory is allocated by the compiler with no reference to things
that are far.

Steve
Technical Details
Message-ID: <189agkINN4jd@usenet.INS.CWRU.Edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bu254
References: <1992Sep4.051057.26963@news2.cis.umn.edu> <1992Sep3.134102.17553@news2.cis.umn.edu> <HOLLEN.92Sep3114500@peg.megatek.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!cleveland.Freenet.Edu!bu254
From: bu254@cleveland.Freenet.Edu (Stephen Groundwater)
Newsgroups: comp.os.msdos.programmer
Subject: Re: New and farcoreleft()
Date: 5 Sep 1992 03:45:24 GMT
Organization: Case Western Reserve University, Cleveland, OH (USA)
Lines: 52
Message-ID: <189agkINN4jd@usenet.INS.CWRU.Edu>
References: <1992Sep4.051057.26963@news2.cis.umn.edu> <1992Sep3.134102.17553@news2.cis.umn.edu> <HOLLEN.92Sep3114500@peg.megatek.UUCP>
Reply-To: bu254@cleveland.Freenet.Edu (Stephen Groundwater)
NNTP-Posting-Host: hela.ins.cwru.edu