[GLIBC][PATCH v2] Remove strdup inlines

Joseph Myers joseph@codesourcery.com
Mon Dec 12 23:11:00 GMT 2016


On Mon, 12 Dec 2016, Wilco Dijkstra wrote:

> this is premature micro optimization. Removing unnecessary string copies
> (why is strdup of a constant string a useful idiom that should be optimized?)

It's useful to strdup constant strings e.g. to ensure that a string in a 
given context is always dynamically allocated, so that subsequent code can 
free it without needing to know where that particular value came from at 
runtime (if some code paths use a constant value, others use a value from 
elsewhere).  (That doesn't answer why it would be performance-relevant.)

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libc-alpha mailing list