Re: Using freetds in Windows

[email protected] (Christos Zoulas)
Newsgroups gmane.comp.db.tds.freetds
Organization Astron Software
Message-ID <[email protected]>
On Jan 11,  9:56pm, [email protected] ("James K. Lowden") wrote:
-- Subject: Re: [freetds] Using freetds in Windows

| Christos Zoulas wrote:
| > I think Win32 strerror(3) is threadsafe. 
| > 
| > Even when doing i18n? 
| 
| AFAIK.  I don't see any technical reason why not.  

Well, to be thread-safe it needs to use per-thread local storage
for the returned string since it cannot know what the string will
contain. It is easier to punt and do the simple:

char *
strerror(int num)
{
        static char buf[NL_TEXTMAX];
        int error = strerror_r(num, buf, sizeof(buf));
        if (error)
                errno = error;
        return buf;
}

This is why one should be using strerror_r() if it exists, or protect
strerror() with a mutex if it does not.

christos
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.