Date: Wed, 31 Dec 1997 11:19:06 -0800 (PST) Message-Id: <199712311919.LAA08200@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: "Richard Sim" , djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: What does/doesn't need memory allocated? Precedence: bulk At 05:59 12/31/1997 +1030, Richard Sim wrote: >Hi, I just spent several days trying to get a routine working because I >forgot to allocate 5 bytes of memory, and I was wondering if there are any >programs/documents that tell you what needs to have memory allocated to it. >i.e. Goes through your code and finds things that need memory allocated to >them, or a text that explains things like this... >Just if you didn't have to allocate memory all of the time...or if there was >something that would tell you what you have to allocate memory for and what >you don't :-). >Oh well, if anyone knows of anything like this could they please tell me >since I really need it. :-) Try compiling with `-Wall'. This may find problems with accessing unallocated memory. Basically, almost every time you pass a pointer to a function, the pointer should point at something accessible. If the data is going to be changed, it needs to not be a constant. > >Also, if say you allocate a structure, do you have to do a free at the end >of your program, or will it be totally free'd anyway? I know that you >should, but must you? No. All memory is automatically freed when your program exits. This should be the case on every system. Nate Eldredge eldredge AT ap DOT net