🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.ibm.pc
Article #42559

msc memory allocation problems

#42559
From: C.S.Curtin
Date: Fri, 16 Feb 1990 21:31
47 lines
1859 bytes


hello MSC5X gurus

	this is using MSC5.1, MS-DOS 4.01.

	i am having a memory problem with calloc/free and have had no
	success checking that the memory has been returned to MS-DOS.
	i have been trying to use the msc function _memavl() (telling
	you how much memory is available) and get the same value
	from _memval() regardless when it is called. (actually i
	would like to do sbrk(0) and verify where the heap point is
	but this does not work for the /AL (Large) model according
	to the manual.

	scenerio:
	>
	>Buffer *bp;
	>
(A)	>fprintf(stderr,"FREE memory %u\n",_memavl());/*print current value*/
	>
	>bp = (Buffer *) calloc(1, sizeof (Buffer));/* allocate memory */
	>
(B)	>fprintf(stderr,"FREE memory %u\n",_memavl());/*print new current value*/
	>
	>free(bp);/* return memory */
	>
(A)	>fprintf(stderr,"FREE memory %u\n",_memavl());
	>

	my feeling is that B should be:
		B = A-sizeof(Buffer);

	but when it is executed A=B;

	the program runs fine otherwise. but i was getting memory allocation
	error cannot load command.com after execution. this occurs only
	when i put the above code in a loop 10,000 times. (just a for loop)
	(i wanted to make darn sure that the memory was getting free'd up 
	after something weird is happening)

	thanks for the help
	any questions/comments/flames please respond via e-mail. thanks for 

	craig curtin
	att!ihlpy!curtin
Technical Details
Message-ID: <13115@cbnewse.ATT.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!mips!apple!motcsd!motsj1!mcdchg!att!cbnewse!curtin

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!mips!apple!motcsd!motsj1!mcdchg!att!cbnewse!curtin
From: curtin@cbnewse.ATT.COM (C.S.Curtin)
Newsgroups: comp.sys.ibm.pc
Subject: msc memory allocation problems
Keywords: calloc()/_memavl()/free()
Message-ID: <13115@cbnewse.ATT.COM>
Date: 16 Feb 90 21:31:24 GMT
Distribution: na
Organization: AT&T Bell Laboratories, Naperville, IL.
Lines: 47