On Sun, Aug 25, 2013 at 01:01:34PM +0200, Holger Hans Peter Freyther wrote:
Hi,
Call things by what they do and this function doesn't allocate anything but it is searching for the first unallocated tbf index.
as part of cleaning up and adding structure (and on the way to eliminate the various hidden errors) I came across tfi_alloc. There are three places that mostly do (the topic of copy and paste in the pcu code is another topic):
tfi = tfi_alloc() if (tfi < 0) return; tbf = tbf_alloc(tfi,...); if (!tbf) return;
Now just by the name... we would leak the result of tfi_alloc in the above code. But then again tfi_alloc doesn't allocate anything it is just trying to find an unallocated index.
Which brings me to: Name things by what they do (and update the name when the implementation does change). In the above case if the method is called tfi_find_free I will know that there is no side-effect and that I will not need to call a tfi_free.
cheers holger