[Asterisk-Dev] sensible buffer size management
    Luigi Rizzo 
    rizzo at icir.org
       
    Wed May  4 02:28:25 MST 2005
    
    
  
It is always good practice to use constants instead of magic numbers
to define the size of data structures, e.g.
	./channels/chan_iax2.c: char context[AST_MAX_EXTENSION];
and not
	./channels/chan_iax2.c: char context[80];
	./pbx/pbx_spool.c:      char context[256];
	./utils/astman.c:       char context[20];
(and the reason should be clear from the above examples which are
grep'ed from today's sources)
Unfortunately it turns out that the vast majority of usages are of
the latter type:
> find . -name \*.\[ch\] -exec grep -H char \{\} \; | egrep '\[[0-9]+' | wc -l
    1672
> find . -name \*.\[ch\] -exec grep -H char \{\} \; | egrep '\[[A-Z]+' | wc -l
     590
Granted some are unavoidable, but in most cases it is just lazy
programming.
If there is interest to clean up this situation at list partly,
i am willing to do a bit of mechanical work
and submit patches to clean up this situation. However, given that
it is a lot of work both on the reporter and the committer side,
I wanted to first ask ...
	cheers
	luigi
    
    
More information about the asterisk-dev
mailing list