Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mcnc!rti!sas!walker From: walker@sas.UUCP (Doug Walker) Newsgroups: comp.sys.amiga.tech Subject: Re: Memory allocation Keywords: stack size, heap, Lattice 5.04 Message-ID: <1411@sas.UUCP> Date: 2 Jan 90 15:57:44 GMT References: <2617@jolnet.ORPK.IL.US> Reply-To: walker@sas.UUCP (Doug Walker) Organization: SAS Institute Inc, Cary NC Lines: 20 In article <2617@jolnet.ORPK.IL.US> caw@jolnet.UUCP (Chris Wichura) writes: >1) Instead of using the char buf[1024] use a char *buf and call your > favorite memory alloc routine (ArpAlloc(), AllocMem(), malloc(), etc) > to get the storage for the buffer and then free the memory after the > copy file routine is done. This will drastically reduce the amount > of stack space your copyfile routine needs. Or, much simpler, just declare the buffer to be global (declare it outside the scope of the function, or put the 'static' keyword on it). Since you only need the buffer during the scope of the routine, this will work for your case. If you really needed a new buffer for each invocation of the routine, you would have to allocate and free each call, but in your case you don't. ***** =*|_o_o|\\=====Doug Walker, Software Distiller======================= *|. o.| || | o |// "READY! FIRE! AIM! (Software under development!) ====== usenet: ...mcnc!rti!sas!walker plink: dwalker bix: djwalker