use our own version of strdup/strndup; close #28