Just use C strdup() instead of handwritten dupstr()