Mercurial > pidgin
comparison libpurple/protocols/jabber/jabber.c @ 24568:6b9552b09de0
Avoid needlessly calling gethostname() if __HOSTNAME__ doesn't appear in the
resource string.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sat, 29 Nov 2008 23:53:50 +0000 |
parents | 5cd0188892f6 |
children | fb5a11ec8be6 6f94b4a27372 b4a2ce33b3d5 aa1fe87558d8 89b95d143116 |
comparison
equal
deleted
inserted
replaced
24567:cff5d920b87f | 24568:6b9552b09de0 |
---|---|
150 char hostname[256]; /* current hostname */ | 150 char hostname[256]; /* current hostname */ |
151 | 151 |
152 /* Empty resource == don't send any */ | 152 /* Empty resource == don't send any */ |
153 if (*input == '\0') | 153 if (*input == '\0') |
154 return NULL; | 154 return NULL; |
155 | |
156 if (strstr(input, "__HOSTNAME__") == NULL) | |
157 return input; | |
155 | 158 |
156 /* Replace __HOSTNAME__ with hostname */ | 159 /* Replace __HOSTNAME__ with hostname */ |
157 if (gethostname(hostname, sizeof(hostname) - 1)) { | 160 if (gethostname(hostname, sizeof(hostname) - 1)) { |
158 purple_debug_warning("jabber", "gethostname: %s\n", g_strerror(errno)); | 161 purple_debug_warning("jabber", "gethostname: %s\n", g_strerror(errno)); |
159 /* according to glibc doc, the only time an error is returned | 162 /* according to glibc doc, the only time an error is returned |