Print this page
Thread safety fixes.

@@ -1,7 +1,7 @@
 /*
- * Copyright 2013 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2002-2004 Tim J. Robbins.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

@@ -35,17 +35,15 @@
 
 int
 mbtowc_l(wchar_t *_RESTRICT_KYWD pwc, const char *_RESTRICT_KYWD s, size_t n,
     locale_t loc)
 {
-        static const mbstate_t initial = { 0 };
-        static mbstate_t mbs;
+        mbstate_t mbs = { 0 };
         size_t rval;
 
         if (s == NULL) {
                 /* No support for state dependent encodings. */
-                mbs = initial;
                 return (0);
         }
         rval = mbrtowc_l(pwc, s, n, &mbs, loc);
         if (rval == (size_t)-1 || rval == (size_t)-2)
                 return (-1);