🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1270

Re: Need help with Turbo C "farmalloc"

#1270
From: James Webster Birdsall
Date: Fri, 09 Feb 1990 18:10
31 lines
2377 bytes
In article <4100@mace.cc.purdue.edu> afc@mace.cc.purdue.edu (Greg Flint) writes:
>The problem that I'm having is that when I request 1-8 bytes, I'm given
>16.  When I request 9-16, I'm given 32 bytes...and so on.  This causes
>me to run out of memory long before I should.  (This is determined by
>calling "farcoreleft" after each "farmalloc" call.)
>-------------------------------------------------------------------------------
>Greg Flint 	  Math G-169   (317) 494-1787   UUCP:  purdue!klaatu.cc!afc
>  Purdue Univ.	  Purdue University	    INTERNET:  afc@klaatu.cc.purdue.edu
>  Computing Ctr.  West Lafayette, IN 47907    BITNET:  flint@purccvm.bitnet

   Since I'm not at my computer just now, I can't say for sure, but I
think that farmalloc is just an interface to the DOS memory-allocation
functions. These, of course, allocate memory in paragraphs. Since
several bytes at the beginning of every memory block are reserved for
system use, when you try for 9 bytes, it has to give you two
paragraphs, etc.
   Worse, there have been the occasional rumors about bugs in DOS's
memory handling functions, leading to system corruption if lots of small
blocks are allocated and released frequently.
   Things you could try: you could try switching to a larger memory
model (one with multiple data segments) and use malloc(). I've never
gotten malloc() to work right in larger memory models, but I've never
tried very hard.
   Otherwise I think you're going to have to write or find a library of
memory-management functions.


-- 
James W. Birdsall  jwbirdsa@phoenix.Princeton.EDU  jwbirdsa@pucc.BITNET
   ...allegra!princeton!phoenix!jwbirdsa   Compu$erve: 71261,1731
"For it is the doom of men that they forget." -- Merlin
Technical Details
Message-ID: <13741@phoenix.Princeton.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sunybcs!uhura.cc.rochester.edu!rochester!udel!princeton!phoenix!jwbirdsa
References: <4100@mace.cc.purdue.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sunybcs!uhura.cc.rochester.edu!rochester!udel!princeton!phoenix!jwbirdsa
From: jwbirdsa@phoenix.Princeton.EDU (James Webster Birdsall)
Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc
Subject: Re: Need help with Turbo C "farmalloc"
Keywords: Turbo C farmalloc
Message-ID: <13741@phoenix.Princeton.EDU>
Date: 9 Feb 90 18:10:29 GMT
References: <4100@mace.cc.purdue.edu>
Reply-To: jwbirdsa@phoenix.Princeton.EDU (James Webster Birdsall)
Followup-To: alt.msdos.programmer
Organization: Princeton University, NJ
Lines: 31