Fix memory management bug + use qsort
Status: Alpha
Brought to you by:
svdbeek
I decided to replace the double bubble sort with a
qsort (the list will be short so it doesn't really
matter from an efficiency point of view, but it makes
for simpler code). In order to do some testing I faked
up 20 devices for it to sort, which caused a crash.
I tracked it down to the mallocs not being large enough
(which won't show up in normal use, since with one
device you overun by only three bytes (or so) which
will be OK due to the malloc grain size).
I've attached a patch including both bits - replacing
the sort function with qsort and mallocing the correct
amount of memory. If the qsort isn't wanted, then the
fixes to the memory allocations should still be applied
- they are real bug fixes.
The patch