diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc index d64e3fdcb..0e8c6d9a9 100644 --- a/winsup/cygwin/smallprint.cc +++ b/winsup/cygwin/smallprint.cc @@ -56,32 +56,26 @@ static const char hex_str_lower[] = "0123456789abcdef"; class tmpbuf { - static WCHAR buf[NT_MAX_PATH]; - static muto lock; - bool locked; + PWCHAR buf; + public: operator WCHAR * () { - if (!locked) - { - lock.init ("smallprint_buf")->acquire (); - locked = true; - } + if (!buf) + buf = (PWCHAR) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, + NT_MAX_PATH * sizeof (WCHAR)); return buf; } - operator char * () {return (char *) ((WCHAR *) *this);} + operator char * () { return (char *) ((WCHAR *) *this); } - tmpbuf (): locked (false) {}; + tmpbuf () : buf (NULL) {} ~tmpbuf () { - if (locked) - lock.release (); + if (buf) + HeapFree (GetProcessHeap (), 0, buf); } }; -WCHAR tmpbuf::buf[NT_MAX_PATH]; -NO_COPY muto tmpbuf::lock; - static char * __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned long long mask) {