rap@rap.ardent.com (Rob Peck) (05/10/89)
Brian Rhodefer responded directly via email to my earlier posting: > > In article <6374@ardent.UUCP> you write: > >"malloc" could be used to allocate these buffers in the first place > >so that the user code need never even "free" the buffers on exit > >since this is usually done when a program exists anyhow. Of course > >it is not good programming practice but if one forgets to tell the > >file requester to deallocate all of the cached file buffers, if the > >filereq.library used malloc, it should not cause any problems. > > > > Are you referring, perhaps, to Manx' "malloc"? It seems this way > because Manx' malloc has this property of "auto-releasing". It has > another property, though: it is most definitely NOT re-entrant. > I don't think you could use it in shared-library code. > > Brian Rhodefer > Yes, I was referring to either Manx or Lattice 'malloc', but not having the source to the libs, would not have been aware that the code was not re-entrant. Would assume, however, that if I re-propose that malloc be used if and only if surrounded with a Forbid/Permit pair, that might solve the problem? Maybe I better find someone that has the source and be sure. Manx malloc uses global variables? Can anyone expand on this? Why would malloc not be useable in shared library code? Anyway, thanks Brian, for responding. May save someone else from a problem. <feeder fodder> Rob Peck
AXDRW%ALASKA.BITNET@cunyvm.cuny.edu (Don R. Withey) (05/11/89)
> From: Rob Peck <rap@rap.ardent.com> on Date: 10 May 89 16:30:37 GMT > > Brian Rhodefer responded directly via email to my earlier posting: >> >> In article <6374@ardent.UUCP> you write: >> >"malloc" could be used to allocate these buffers in the first place Yup bad idea... >> Are you referring, perhaps, to Manx' "malloc"? It seems this way >> because Manx' malloc has this property of "auto-releasing". It also probably won't work with Lattice startup/exit code, stick with the system functions. >> > Yes, I was referring to either Manx or Lattice 'malloc', but not having > the source to the libs, would not have been aware that the code was not > re-entrant. Would assume, however, that if I re-propose that malloc > be used if and only if surrounded with a Forbid/Permit pair, that might > solve the problem? Maybe I better find someone that has the source and > be sure. Manx malloc uses global variables? Can anyone expand on this? > Why would malloc not be useable in shared library code? Anyway, thanks > Brian, for responding. May save someone else from a problem. > It would be better to use AllocRemember and attach the remember list to your task structure, this way when your task goes away, the system will automatically deallocate the memory. I'm not too sure about the details, but I know that CreateTask does something like this with the stack it allocates for your task, so that when you RemTask yourself, the stack goes away automatically. This seems like the way to go, I assume that since CreateTask is a support library routine in Amiga.lib, and RemTask lives in the Exec.library that what CreateTask does is legal to do elsewhere. [...feeder fodder deleted] > Rob Peck Don ------------------------------------------------------------- Snail Mail: Don R. Withey, 3700 East 65th Ave, Anch, AK 99507 Phone: 907-786-1074 (work), 907-344-4057 (home) Email: Bitnet: axdrw@alaska.bitnet BIX: dwithey University of AK Anch, Computing & Technology Services (CATS ;-) -------------------------------------------------------------