X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com Date: Mon, 14 Mar 2016 08:44:15 +0100 (CET) X-X-Sender: igor2 AT igor2priv To: geda-user AT delorie DOT com X-Debug: to=geda-user AT delorie DOT com from="gedau AT igor2 DOT repo DOT hu" From: gedau AT igor2 DOT repo DOT hu Subject: Re: [geda-user] pcb: more memory leaks In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Yet another round of leak hunting; same remarks as before. 1. Easy - file.c/PrintQuotedString() keeps a cache of a dynamic string that is never free()'d. My solution was to make the string a static global and add a file_uninit() that can free it at the end (r1256). On the long run I won't keep this mechanism: there's no much reason not to print to the file directly while doing the quoting so there would be no need for allocation at all. - parse_y.y: in rule "layer", before Layer->Name = $4, Layer->Name should be free()'d if it is not NULL. It is because a PCB->Data at any stage contains strdup()'d layer names; creating the pcb strdups the default names from Settings which are overwritten by the parser. If the original names are not free()'d, it's a few bytes of leak for each layer for each parse operation (load, load layout into buffer). (r1257) 2. Hard n/a 3. off topic not a leak, just wondering: hid/common/flags.c:hid_find_init() why do we implement bsearch() in the second half of the function instead of just calling it, especially that we did not implement our own qsort()? bsearch() should be as portable as qsort() - both are C89. (In pcb-rnd I've replaced the whole thing with a string->pointer hash, so I don't need a linked list, an array and a flag to remember whether the array is sorted, etc - shorter, simpler, faster code (r1261)).