bug #34302: Feature request : device configuration with parent classes

* config_gram.y: if memory section is overwritten old entry is removed
        
(not in original patch)
* config_gram.y: if programmer or part is defined twice, a warning is
  output and the first instance is removed
        
General cleanup and free functions, so valgrind does not report any lost
blocks at program end.
* avrpart.[hc]: added avr_free_(opcode|mem|part) functions
* pgm.[hc]: added pgm_free function
* update.[hc]: added free_update functions
* config.[hc]: added cleanup_config function, use yylex_destroy to reset
  the lexer after usage. (So it can be reused.)
* main.c: add cleanup_main function which is called by atexit() (This 
  frees all lists so that at program exit only really lost memory is 
  reported by valgrind.)
* usbasp.c: added libusb_free_device_list() and libusb_exit() calls to
  avoid lost memory
* buspirate.c: moved memory allocation from initpgm to setup and added 
  free in teardown
* configure.ac: add definition of HAVE_YYLEX_DESTROY if $LEX is flex.
* Makefile.am: added . in front of SUBDIRS to build avrdude before trying
  to use it for creating the part list for the docs.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@1041 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Rene Liebscher
2012-01-17 20:56:37 +00:00
parent fe7be6301e
commit 459aa147e7
15 changed files with 203 additions and 18 deletions

View File

@@ -71,11 +71,11 @@ struct list_walk_cookie
const char *prefix;
};
static LISTID updates;
static LISTID updates = NULL;
static LISTID extended_params;
static LISTID extended_params = NULL;
static LISTID additional_config_files;
static LISTID additional_config_files = NULL;
static PROGRAMMER * pgm;
@@ -254,6 +254,24 @@ static void exithook(void)
pgm->teardown(pgm);
}
static void cleanup_main(void)
{
if (updates) {
ldestroy_cb(updates,free_update);
updates = NULL;
}
if (extended_params) {
ldestroy(extended_params);
extended_params = NULL;
}
if (additional_config_files) {
ldestroy(additional_config_files);
additional_config_files = NULL;
}
cleanup_config();
}
/*
* main routine
*/
@@ -332,6 +350,8 @@ int main(int argc, char * argv [])
init_config();
atexit(cleanup_main);
updates = lcreat(NULL, 0);
if (updates == NULL) {
fprintf(stderr, "%s: cannot initialize updater list\n", progname);