Mercurial > pidgin.yaz
changeset 6269:0a902bd3e170
[gaim-migrate @ 6766]
I'm going to be boiled alive for this.. Changing
gaim_xfers_get_local_system_ip() to use a static buffer that it returns
instead of a g_strdup()'d copy of the buffer... but that's rarely of use,
because I don't think the IP will be changing often enough where this will
screw up code :P Also, fixed a function's name, because I broke compiling
again.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 22 Jul 2003 08:22:08 +0000 |
parents | 084e1f6610a8 |
children | 1bf6fd117797 |
files | src/ft.c src/ft.h |
diffstat | 2 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ft.c Tue Jul 22 08:12:08 2003 +0000 +++ b/src/ft.c Tue Jul 22 08:22:08 2003 +0000 @@ -45,7 +45,7 @@ xfer->who = g_strdup(who); xfer->ui_ops = gaim_get_xfer_ui_ops(); - xfer->local_ip = gaim_xfers_get_ip_for_account(account); + xfer->local_ip = g_strdup(gaim_xfers_get_ip_for_account(account)); ui_ops = gaim_xfer_get_ui_ops(xfer); @@ -723,13 +723,13 @@ return ip; } -char * +const char * gaim_xfers_get_local_system_ip(void) { struct hostent *host; char localhost[129]; long unsigned add; - char ip[46]; + static char ip[46]; if (gethostname(localhost, 128) < 0) return NULL; @@ -742,18 +742,18 @@ g_snprintf(ip, 11, "%lu", add); - return g_strdup(ip); + return ip; } -char * +const char * gaim_xfers_get_ip_for_account(const GaimAccount *account) { g_return_val_if_fail(account != NULL, NULL); if (gaim_account_get_public_ip(account) != NULL) - return g_strdup(gaim_account_get_public_ip(account)); + return gaim_account_get_public_ip(account); else if (gaim_xfers_get_local_ip() != NULL) - return g_strdup(gaim_xfers_get_local_ip()); + return gaim_xfers_get_local_ip(); else return gaim_xfers_get_local_system_ip(); }
--- a/src/ft.h Tue Jul 22 08:12:08 2003 +0000 +++ b/src/ft.h Tue Jul 22 08:22:08 2003 +0000 @@ -486,12 +486,13 @@ /** * Returns the IP address of the local system. * - * @note The returned IP address must be g_free()'d when no longer - * in use. + * @note The returned string is a pointer to a static buffer. If this + * function is called twice, it may be important to make a copy + * of the returned string. * * @return The local IP address. */ -char *gaim_xfers_get_local_system__ip(void); +const char *gaim_xfers_get_local_system_ip(void); /** * Returns the IP address that should be used for the specified account. @@ -507,11 +508,13 @@ * @note The returned IP address must be g_free()'d when no longer * in use. * - * @param account The account the IP is going to be used with. + * @note The returned string is a pointer to a static buffer. If this + * function is called twice, it may be important to make a copy + * of the returned string. * * @return The local IP address to be used. */ -char *gaim_xfers_get_ip_for_account(const GaimAccount *account); +const char *gaim_xfers_get_ip_for_account(const GaimAccount *account); /** * Initializes the file transfer subsystem.