Re: [Dev-C++] RES: RES: Question about software design
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2007-11-21 13:05:47
|
The free() before program termination isn't needed when the application is run under any normal operating system. But when talking embedded systems, there is normally no such resource manager available in the OS - if there even is an OS. Cleaning up memory is a good thing to do even when not needed. One reason is that you can use automatic tools to find memory leaks - the allocations that you have forgotten, and that may be located inside some form of loop and result in a program failure after some time because you run out of memory. Without a free() at the end of program, the test will always complain about "lost" memory, and you will always ignore the result of the test - so you will not notice these unexpected leaks. One example of an often forgotten leak is strdup(). /pwm On Wed, 21 Nov 2007, Andr=E9 Mac=E1rio Barros wrote: > I understood that you are asking about the advances C++ can > give us in these aspects, right? > > My interest is to focus the code only in ANSI C for some reasons. > One of them is to put the same code in a C-microcontroler, like > PIC16F877, with a minimum level of modification. > > But, let me make one question related to this: I=B4ve read here that > the free() command isn=B4t necessary, is it? At the end of the execution > of the program all the dynamic memory requested is released > automatically. Is that true? > > Regards > Andre > -----Mensagem original----- > De: Rafael Menezes [mailto:so...@gm...] > Enviada em: quarta-feira, 21 de novembro de 2007 01:18 > Para: Andr=E9 Mac=E1rio Barros > Cc: Lista do Dev-C++ > Assunto: Re: [Dev-C++] RES: Question about software design > > > Sorry Chris.... > > So.... you just don't like to use new and delete, correct? That isn't t= he > ready-to-go way to alloc memory, use for any time and free as you wish, i= n > c++ (I use that all the time. Truly, I don't use static variables anymore= , > in C and C++.)? (same is true to c with free and calloc). This approach c= an > be very useful if you are not interested in reinvent the wheel (Like proo= f > of concept and other study cases.) > > > -- > Regards > Rafael Menezes > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.503 / Virus Database: 269.16.2/1142 - Release Date: 20/11/20= 07 > 17:44 > |