Print this page
Thread safety fixes.

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/setrunelocale.c
          +++ new/usr/src/lib/libc/port/locale/setrunelocale.c
↓ open down ↓ 58 lines elided ↑ open up ↑
  59   59          .lc_wcsnrtombs = __wcsnrtombs_ascii,
  60   60          .lc_is_ascii = 1,
  61   61          .lc_max_mblen = 1,
  62   62          .lc_trans_upper = _DefaultRuneLocale.__mapupper,
  63   63          .lc_trans_lower = _DefaultRuneLocale.__maplower,
  64   64          .lc_ctype_mask = _DefaultRuneLocale.__runetype,
  65   65  };
  66   66  
  67   67  struct locdata __posix_ctype_locdata = {
  68   68          .l_lname = "C",
  69      -        .l_refcnt = (uint32_t)-1,
  70   69          .l_data = { &lc_ctype_posix, &_DefaultRuneLocale }
  71   70  };
  72   71  
  73   72  
  74   73  /*
  75   74   * Table of initializers for encodings.  When you add a new encoding type,
  76   75   * this table should be updated.
  77   76   */
  78   77  static struct {
  79   78          const char *e_name;
↓ open down ↓ 27 lines elided ↑ open up ↑
 107  106                  return (NULL);
 108  107          lct = ldata->l_data[0];
 109  108          /*
 110  109           * Slurp the locale file into the cache.
 111  110           */
 112  111  
 113  112          (void) snprintf(path, sizeof (path), "%s/%s/LC_CTYPE/LCL_DATA",
 114  113              _PathLocale, name);
 115  114  
 116  115          if ((rl = _Read_RuneMagi(path)) == NULL) {
 117      -                __locdata_release(ldata);
      116 +                __locdata_free(ldata);
 118  117                  errno = EINVAL;
 119  118                  return (NULL);
 120  119          }
 121  120          ldata->l_data[1] = rl;
 122  121  
 123  122          lct->lc_mbrtowc = NULL;
 124  123          lct->lc_mbsinit = NULL;
 125  124          lct->lc_mbsnrtowcs = NULL;
 126  125          lct->lc_wcrtomb = NULL;
 127  126          lct->lc_wcsnrtombs = NULL;
↓ open down ↓ 4 lines elided ↑ open up ↑
 132  131          /* set up the function pointers */
 133  132          for (i = 0; encodings[i].e_name != NULL; i++) {
 134  133                  int l = strlen(encodings[i].e_name);
 135  134                  if ((strncmp(rl->__encoding, encodings[i].e_name, l) == 0) &&
 136  135                      (rl->__encoding[l] == '\0' || rl->__encoding[l] == '@')) {
 137  136                          encodings[i].e_init(lct);
 138  137                          break;
 139  138                  }
 140  139          }
 141  140          if (encodings[i].e_name == NULL) {
 142      -                __locdata_release(ldata);
      141 +                __locdata_free(ldata);
 143  142                  errno = EINVAL;
 144  143                  return (NULL);
 145  144          }
 146  145  
 147  146  
 148  147          return (ldata);
 149  148  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX