improved b_strdup; added b_strndup