From: Christian H. <ch...@us...> - 2003-07-22 08:22:15
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1:/tmp/cvs-serv9365 Modified Files: ft.c ft.h Log Message: 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. Index: ft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/ft.c,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- ft.c 22 Jul 2003 08:12:08 -0000 1.44 +++ ft.c 22 Jul 2003 08:22:08 -0000 1.45 @@ -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(); } Index: ft.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/ft.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- ft.h 22 Jul 2003 08:12:08 -0000 1.20 +++ ft.h 22 Jul 2003 08:22:08 -0000 1.21 @@ -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. |