Re: [Mingw-users] Porting localtime_r and gmtime_r
- Date: Mon, 04 Feb 2008 18:31:47 -0800
- From: Brian Dessent <brian@xxxxxxxxxxx>
- Subject: Re: [Mingw-users] Porting localtime_r and gmtime_r
JonY wrote:
> Are there any immediate problems with it? If yes, please advice.
No, that won't work. Well, it might work for a single threaded app but
it is certainly not correct. The reason that you need a re-entrant (_r)
version of these functions is that the original ones use a static
buffer. This means that if two or more threads are in contention the
buffer can change between calls. In other words, what you have is no
good because the value of the buffer can change before it has been
memcpy()'d to result because there is only one static buffer shared by
all callers.
Brian
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users