Best way of cloning (compiled) regex_t struct in C
<p>Looking to the <a href="http://linux.die.net/man/3/regex" rel="nofollow">regex_t man page</a>, there is a <code>regcomp()</code> function that compiles a <code>regex_t</code> struct from a string and a dual function <code>regfree()</code> to free the <code>regex_t</code> (I understand that freeing is needed due to <code>regex_t</code> uses some dynamic memory internally).</p>

<p>However, that manual page doesn't mention a function to clone a compiled <code>regex_t</code> into another <code>regex_t</code> struct. Is there any way of doing that?</p>

<p>The only mechanism that I can figure out is re-compiling from the source string, but I guess that is less efficient than just copy at <code>regex_t</code>level.</p>