addr_parsing: rename mount_resolve_dest to resolve_addrs and don't modify its argument

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
This commit is contained in:
Josh Durgin 2011-04-15 15:19:26 -07:00
parent bffb9edfd0
commit def36668a1
3 changed files with 6 additions and 5 deletions

View File

@ -39,11 +39,13 @@ int safe_cat(char **pstr, int *plen, int pos, const char *str2)
return pos + len2;
}
char *mount_resolve_dest(char *orig_str)
char *resolve_addrs(const char *orig_str)
{
char *new_str;
char *tok, *p, *port_str;
int len, pos;
char buf[strlen(orig_str) + 1];
strcpy(buf, orig_str);
len = BUF_SIZE;
new_str = (char *)malloc(len);
@ -51,7 +53,7 @@ char *mount_resolve_dest(char *orig_str)
p = new_str;
pos = 0;
tok = strtok(orig_str, ",");
tok = strtok(buf, ",");
while (tok) {
struct addrinfo hint;

View File

@ -19,7 +19,7 @@ int safe_cat(char **pstr, int *plen, int pos, const char *str2);
/*
* returns a string allocated by malloc; caller must free
*/
char *mount_resolve_dest(char *orig_str);
char *resolve_addrs(const char *orig_str);
#ifdef __cplusplus
}

View File

@ -86,8 +86,7 @@ int MonClient::build_initial_monmap()
} else { //maybe they passed us a DNS-resolvable name
char *hosts = NULL;
char *old_addrs = new char[g_conf.mon_host.size() + 1];
strcpy(old_addrs, g_conf.mon_host.c_str());
hosts = mount_resolve_dest(old_addrs);
hosts = resolve_addrs(old_addrs);
delete [] old_addrs;
if (!hosts)
return -EINVAL;