On Oct 16, 2013, at 6:27 AM, Tom Browder wrote:

> The pid and files usage was a stupid move to avoid malloc, but the
> better solution is using static buffers akin to bu_progname (but not
> yet implemented).

There's a concern with heap memory?  I wouldn't think there's an issue for an 
argument interface.

Mildly related, note that bu_progname() isn't really the best example to 
follow.  It has to use a static buffer, not because it's a good thing to do.  
It uses that method because it tries to implement what POSIX defines for 
getprogname()'s behavior.  It's not parallel-safe and there's no easy way for 
making it safe without being non-conformant.  It's actually a strong case for 
implementing a different non-drop-in replacement where the caller passes their 
buffer in instead of trying to behaving like getprogname().

Thread-safety isn't necessarily important for argument parsing, of course, but 
I'd suggest avoiding static buffers in any library code whenever possible.  We 
obviously violate this in several places, but usually out of necessity or 
laziness.

Cheers!
Sean


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to