Mail Archives: geda-user/2016/03/14/03:41:03
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)).
- Raw text -