On Tue, 3 Jan 2012 09:52:11 +0100 Stefan Tauner stefan.tauner@student.tuwien.ac.at wrote:
I tried to get the code right this time, but now it leaks lb_part and lb_vendor allocations (consistent with other places setting lb_part and lb_vendor) and we'd have to free them in some internal_shutdown handler.
well that's not the only problem imo. you can't free tempstr like that, because it gets modified by strtok. i am not 100% sure what your version would do actually. the address tempstr points to, may be one that was not (the start of) an allocated area. what does calling free on that do according to the standard?
uh... too early. strike all of that. of course the reference itself cant be changed out of the function itself just the referenced data/string is changed. so it points to the same address all of the time and your version is fine actually.
please look further below ...
no, please dont :)