[5/5] ws2_32: Move the buffer used by inet_ntoa into the per thread data.
Dmitry Timoshkov
dmitry at baikal.ru
Wed Dec 11 02:05:01 CST 2013
---
dlls/ws2_32/socket.c | 16 ++++++++--------
dlls/ws2_32/tests/sock.c | 1 -
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index e4e246d..495d50a 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -378,6 +378,11 @@ struct per_thread_data
int he_len;
int se_len;
int pe_len;
+ /* use "buffer for dummies" here because some applications have a
+ * propensity to decode addresses in ws_hostent structure without
+ * saving them first...
+ */
+ char dbuffer[16]; /* Yes, 16: 4*3 digits + 3 '.' + 1 '\0' */
};
/* internal: routing description information */
@@ -3525,17 +3530,12 @@ WS_u_short WINAPI WS_ntohs(WS_u_short netshort)
*/
char* WINAPI WS_inet_ntoa(struct WS_in_addr in)
{
- /* use "buffer for dummies" here because some applications have a
- * propensity to decode addresses in ws_hostent structure without
- * saving them first...
- */
- static char dbuffer[16]; /* Yes, 16: 4*3 digits + 3 '.' + 1 '\0' */
-
char* s = inet_ntoa(*((struct in_addr*)&in));
if( s )
{
- strcpy(dbuffer, s);
- return dbuffer;
+ struct per_thread_data *data = get_per_thread_data();
+ strcpy(data->dbuffer, s);
+ return data->dbuffer;
}
SetLastError(wsaErrno());
return NULL;
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 40e12a0..341b7e7 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -7073,7 +7073,6 @@ static void test_inet_ntoa(void)
thread = CreateThread(NULL, 0, inet_ntoa_thread_proc, event, 0, &tid);
WaitForSingleObject(event[0], 3000);
-todo_wine
ok(!strcmp(str, "1.2.3.4"), "expected 1.2.3.4, got %s\n", str);
SetEvent(event[1]);
--
1.8.5.1
More information about the wine-patches
mailing list