Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 13268) +++ trunk/scconfig/Rev.h (revision 13269) @@ -1 +1 @@ -static const int myrev = 13171; +static const int myrev = 13269; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 13268) +++ trunk/scconfig/Rev.tab (revision 13269) @@ -1,3 +1,4 @@ +13269 configure remove free_atexit 13171 configure io_eagle: new source file for parsing dru files 13037 configure code simplification: PCB_INLINE 12835 configure new plugin: shape Index: trunk/src/free_atexit.c =================================================================== --- trunk/src/free_atexit.c (revision 13268) +++ trunk/src/free_atexit.c (nonexistent) @@ -1,110 +0,0 @@ -/* COPYRIGHT - * - * Copyright (C) 2010 PCB Contributors (see ChangeLog for details) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact addresses for paper mail and Email: - * harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA - * haceaton@aplcomm.jhuapl.edu - * - */ - -#include -#include -#include "config.h" - -/* we need one ID per context - short int with 64k IDs should be enough */ -typedef unsigned int leaky_idx_t; - - -/* This structure should be as big as void *, which should be the natural -bit-width of the architecture. We allocate extra admin space to be as big -as this union, to preserve alignment of pointers returned by malloc(). -NOTE: in the special corner case when leaky_idx_t is wider than void * but -not multiple of it, the alignment will be messed up, potentially causing slower -memory access. */ -typedef union { - leaky_idx_t idx; - void *ptr; -} leaky_admin_t; - -static void **free_list = NULL; -static leaky_idx_t free_size = 0; - - -void *pcb_leaky_malloc(size_t size) -{ - char *new_memory = malloc(size + sizeof(leaky_admin_t)); - - free_list = (void **) realloc(free_list, (free_size + 1) * sizeof(void *)); - free_list[free_size] = new_memory; - *(leaky_idx_t *) new_memory = free_size; - - free_size++; - return new_memory + sizeof(leaky_admin_t); -} - -void *pcb_leaky_calloc(size_t nmemb, size_t size) -{ - size_t size_ = size * nmemb; - void *new_memory = pcb_leaky_malloc(size_); - - memset(new_memory, 0, size_); - return new_memory; -} - -void *pcb_leaky_realloc(void *old_memory_, size_t size) -{ - char *new_memory; - char *old_memory = old_memory_; - leaky_idx_t i; - - if (old_memory == NULL) - return pcb_leaky_malloc(size); - - old_memory -= sizeof(leaky_admin_t); - - i = *(leaky_idx_t *) old_memory; - - new_memory = realloc(old_memory, size + sizeof(leaky_admin_t)); - free_list[i] = new_memory; - - return new_memory + sizeof(leaky_admin_t); -} - -char *pcb_leaky_strdup(const char *src) -{ - int len = strlen(src)+1; - char *res = pcb_leaky_malloc(len); - memcpy(res, src, len); - return res; -} - -void pcb_leaky_uninit(void) -{ - int i; - - for (i = 0; i < free_size; i++) - free(free_list[i]); - - free(free_list); - free_size = 0; -} - -void pcb_leaky_init(void) -{ - atexit(pcb_leaky_uninit); -} Index: trunk/src/free_atexit.h =================================================================== --- trunk/src/free_atexit.h (revision 13268) +++ trunk/src/free_atexit.h (nonexistent) @@ -1,38 +0,0 @@ -/* This tiny library is to assist cleaning up harmless memory leaks caused - by (growing) buffers allocated in static variables in functions. The - library provides pcb_leaky_ prefixed variants of the common allocation - routines. These wrappers will remember all pointers they return and - can free all memory used, at the end of the application. -*/ - -#include - -#ifdef NDEBUG -#define pcb_leaky_init() -#define pcb_leaky_uninit() -#define pcb_leaky_malloc(size) malloc(size) -#define pcb_leaky_calloc(nmemb, size) calloc(nmemb, size) -#define pcb_leaky_realloc(old_memory, size) realloc(old_memory, size) -#define pcb_leaky_strdup(str) strdup(str) -#else - -/* set up atexit() hook - can be avoided if pcb_leaky_uninit() is called by hand */ -void pcb_leaky_init(void); - -/* free all allocations */ -void pcb_leaky_uninit(void); - -/* allocate memory, remember the pointer and free it after exit from the application */ -void *pcb_leaky_malloc(size_t size); - -/* same as leaky_malloc but this one wraps calloc() */ -void *pcb_leaky_calloc(size_t nmemb, size_t size); - -/* reallocate memory, remember the new pointer and free it after exit from the application */ -void *pcb_leaky_realloc(void *old_memory, size_t size); - -/* strdup() using pcb_leaky_malloc() */ -char *pcb_leaky_strdup(const char *src); - - -#endif Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 13268) +++ trunk/src/Makefile.dep (revision 13269) @@ -5671,7 +5671,6 @@ ../src_3rd/genht/htsp.h ../src_3rd/genvector/vtp0.h list_conf.h \ plug_io.h event.h fptr_cast.o: fptr_cast.c ../config.h fptr_cast.h -free_atexit.o: free_atexit.c ../config.h funchash.o: funchash.c ../src_3rd/genht/htpi.h ../src_3rd/genht/ht.h \ ../src_3rd/genht/hash.h funchash_core.h funchash.h funchash_core_list.h \ ../config.h macro.h compat_misc.h @@ -6046,7 +6045,7 @@ ../src_3rd/genvector/gds_char.h ../src_3rd/liblihata/lihata.h \ ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ ../src_3rd/liblihata/parser.h ../src_3rd/genvector/vtp0.h list_conf.h \ - compat_lrealpath.h free_atexit.h buildin.h ../src_3rd/puplug/libs.h \ + compat_lrealpath.h buildin.h ../src_3rd/puplug/libs.h \ ../src_3rd/puplug/puplug.h ../src_3rd/puplug/os_dep.h \ ../src_3rd/puplug/config.h ../src_3rd/puplug/libs.h build_run.h \ flag_str.h plugins.h ../src_3rd/puplug/error.h plug_footprint.h \ Index: trunk/src/Makefile.in =================================================================== --- trunk/src/Makefile.in (revision 13268) +++ trunk/src/Makefile.in (revision 13269) @@ -53,7 +53,6 @@ find_act.o flag.o flag_str.o - free_atexit.o funchash.o gui_act.o heap.o Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 13268) +++ trunk/src/main.c (revision 13269) @@ -47,7 +47,6 @@ #include "buffer.h" #include "crosshair.h" #include "compat_lrealpath.h" -#include "free_atexit.h" #include "polygon.h" #include "buildin.h" #include "build_run.h" @@ -422,13 +421,6 @@ pcb_units_init(); pcb_polygon_init(); - /* This must be called before any other atexit functions - * are registered, as it configures an atexit function to - * clean up and free various items of allocated memory, - * and must be the last last atexit function to run. - */ - pcb_leaky_init(); - /* Register a function to be called when the program terminates. * This makes sure that data is saved even if LEX/YACC routines * abort the program. Index: work/obsolete/free_atexit.c =================================================================== --- work/obsolete/free_atexit.c (nonexistent) +++ work/obsolete/free_atexit.c (revision 13269) @@ -0,0 +1,110 @@ +/* COPYRIGHT + * + * Copyright (C) 2010 PCB Contributors (see ChangeLog for details) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact addresses for paper mail and Email: + * harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA + * haceaton@aplcomm.jhuapl.edu + * + */ + +#include +#include +#include "config.h" + +/* we need one ID per context - short int with 64k IDs should be enough */ +typedef unsigned int leaky_idx_t; + + +/* This structure should be as big as void *, which should be the natural +bit-width of the architecture. We allocate extra admin space to be as big +as this union, to preserve alignment of pointers returned by malloc(). +NOTE: in the special corner case when leaky_idx_t is wider than void * but +not multiple of it, the alignment will be messed up, potentially causing slower +memory access. */ +typedef union { + leaky_idx_t idx; + void *ptr; +} leaky_admin_t; + +static void **free_list = NULL; +static leaky_idx_t free_size = 0; + + +void *pcb_leaky_malloc(size_t size) +{ + char *new_memory = malloc(size + sizeof(leaky_admin_t)); + + free_list = (void **) realloc(free_list, (free_size + 1) * sizeof(void *)); + free_list[free_size] = new_memory; + *(leaky_idx_t *) new_memory = free_size; + + free_size++; + return new_memory + sizeof(leaky_admin_t); +} + +void *pcb_leaky_calloc(size_t nmemb, size_t size) +{ + size_t size_ = size * nmemb; + void *new_memory = pcb_leaky_malloc(size_); + + memset(new_memory, 0, size_); + return new_memory; +} + +void *pcb_leaky_realloc(void *old_memory_, size_t size) +{ + char *new_memory; + char *old_memory = old_memory_; + leaky_idx_t i; + + if (old_memory == NULL) + return pcb_leaky_malloc(size); + + old_memory -= sizeof(leaky_admin_t); + + i = *(leaky_idx_t *) old_memory; + + new_memory = realloc(old_memory, size + sizeof(leaky_admin_t)); + free_list[i] = new_memory; + + return new_memory + sizeof(leaky_admin_t); +} + +char *pcb_leaky_strdup(const char *src) +{ + int len = strlen(src)+1; + char *res = pcb_leaky_malloc(len); + memcpy(res, src, len); + return res; +} + +void pcb_leaky_uninit(void) +{ + int i; + + for (i = 0; i < free_size; i++) + free(free_list[i]); + + free(free_list); + free_size = 0; +} + +void pcb_leaky_init(void) +{ + atexit(pcb_leaky_uninit); +} Index: work/obsolete/free_atexit.h =================================================================== --- work/obsolete/free_atexit.h (nonexistent) +++ work/obsolete/free_atexit.h (revision 13269) @@ -0,0 +1,38 @@ +/* This tiny library is to assist cleaning up harmless memory leaks caused + by (growing) buffers allocated in static variables in functions. The + library provides pcb_leaky_ prefixed variants of the common allocation + routines. These wrappers will remember all pointers they return and + can free all memory used, at the end of the application. +*/ + +#include + +#ifdef NDEBUG +#define pcb_leaky_init() +#define pcb_leaky_uninit() +#define pcb_leaky_malloc(size) malloc(size) +#define pcb_leaky_calloc(nmemb, size) calloc(nmemb, size) +#define pcb_leaky_realloc(old_memory, size) realloc(old_memory, size) +#define pcb_leaky_strdup(str) strdup(str) +#else + +/* set up atexit() hook - can be avoided if pcb_leaky_uninit() is called by hand */ +void pcb_leaky_init(void); + +/* free all allocations */ +void pcb_leaky_uninit(void); + +/* allocate memory, remember the pointer and free it after exit from the application */ +void *pcb_leaky_malloc(size_t size); + +/* same as leaky_malloc but this one wraps calloc() */ +void *pcb_leaky_calloc(size_t nmemb, size_t size); + +/* reallocate memory, remember the new pointer and free it after exit from the application */ +void *pcb_leaky_realloc(void *old_memory, size_t size); + +/* strdup() using pcb_leaky_malloc() */ +char *pcb_leaky_strdup(const char *src); + + +#endif