msvcrt: Change the way how localtime/gmtime buffer is stored in __thread_data.

This commit is contained in:
Piotr Caban 2011-05-24 17:22:54 +02:00 committed by Alexandre Julliard
parent e15ac98cbc
commit 12229aeeb2
3 changed files with 12 additions and 5 deletions

View File

@ -73,6 +73,7 @@ static inline void msvcrt_free_tls_mem(void)
HeapFree(GetProcessHeap(),0,tls->wasctime_buffer);
HeapFree(GetProcessHeap(),0,tls->strerror_buffer);
HeapFree(GetProcessHeap(),0,tls->wcserror_buffer);
HeapFree(GetProcessHeap(),0,tls->time_buffer);
free_locinfo(tls->locinfo);
free_mbcinfo(tls->mbcinfo);
}

View File

@ -172,7 +172,7 @@ struct __thread_data {
void *unk2[4];
char *asctime_buffer; /* buffer for asctime */
MSVCRT_wchar_t *wasctime_buffer; /* buffer for wasctime */
struct MSVCRT_tm time_buffer; /* buffer for localtime/gmtime */
struct MSVCRT_tm *time_buffer; /* buffer for localtime/gmtime */
char *efcvt_buffer; /* buffer for ecvt/fcvt */
int unk3[2];
void *unk4[4];

View File

@ -212,10 +212,13 @@ struct MSVCRT_tm* CDECL MSVCRT__localtime64(const MSVCRT___time64_t* secs)
}
data = msvcrt_get_thread_data();
unix_tm_to_msvcrt( &data->time_buffer, tm );
if(!data->time_buffer)
data->time_buffer = MSVCRT_malloc(sizeof(struct MSVCRT_tm));
unix_tm_to_msvcrt( data->time_buffer, tm );
_munlock(_TIME_LOCK);
return &data->time_buffer;
return data->time_buffer;
}
/*********************************************************************
@ -344,9 +347,12 @@ struct MSVCRT_tm* CDECL MSVCRT__gmtime64(const MSVCRT___time64_t *secs)
{
thread_data_t * const data = msvcrt_get_thread_data();
if(MSVCRT__gmtime64_s(&data->time_buffer, secs))
if(!data->time_buffer)
data->time_buffer = MSVCRT_malloc(sizeof(struct MSVCRT_tm));
if(MSVCRT__gmtime64_s(data->time_buffer, secs))
return NULL;
return &data->time_buffer;
return data->time_buffer;
}
/*********************************************************************