Print this page
smatch clean rtld


 211  *
 212  * Presently we support two domains (libc's strerror() uses SUNW_OST_OSLIB).
 213  * If ld.so.1's dependencies evolve to require more then the `domain' array
 214  * maintained below can be enlarged or made more dynamic in nature.
 215  */
 216 char *
 217 dgettext(const char *domain, const char *msgid)
 218 {
 219         static int      domaincnt = 0;
 220         static Domain   *domains;
 221         Domain          *_domain;
 222         int             cnt;
 223 
 224         if (glcs[CI_LCMESSAGES].lc_un.lc_val == 0)
 225                 return ((char *)msgid);
 226 
 227         /*
 228          * Determine if we've initialized any domains yet.
 229          */
 230         if (domaincnt == 0) {
 231                 if ((domains = calloc(sizeof (Domain), 2)) == NULL)
 232                         return ((char *)msgid);
 233                 domains[0].dom_name = MSG_ORIG(MSG_SUNW_OST_SGS);
 234                 domains[1].dom_name = MSG_ORIG(MSG_SUNW_OST_OSLIB);
 235                 domaincnt = 2;
 236         }
 237 
 238         /*
 239          * If this is a new locale make sure we clean up any old ones.
 240          */
 241         if (rtld_flags & RT_FL_NEWLOCALE) {
 242                 cnt = 0;
 243 
 244                 for (_domain = domains; cnt < domaincnt; _domain++, cnt++) {
 245                         if (_domain->dom_msghdr == 0)
 246                                 continue;
 247 
 248                         if (_domain->dom_msghdr != (Msghdr *)-1)
 249                                 (void) munmap((caddr_t)_domain->dom_msghdr,
 250                                     _domain->dom_msgsz);
 251 




 211  *
 212  * Presently we support two domains (libc's strerror() uses SUNW_OST_OSLIB).
 213  * If ld.so.1's dependencies evolve to require more then the `domain' array
 214  * maintained below can be enlarged or made more dynamic in nature.
 215  */
 216 char *
 217 dgettext(const char *domain, const char *msgid)
 218 {
 219         static int      domaincnt = 0;
 220         static Domain   *domains;
 221         Domain          *_domain;
 222         int             cnt;
 223 
 224         if (glcs[CI_LCMESSAGES].lc_un.lc_val == 0)
 225                 return ((char *)msgid);
 226 
 227         /*
 228          * Determine if we've initialized any domains yet.
 229          */
 230         if (domaincnt == 0) {
 231                 if ((domains = calloc(2, sizeof (Domain))) == NULL)
 232                         return ((char *)msgid);
 233                 domains[0].dom_name = MSG_ORIG(MSG_SUNW_OST_SGS);
 234                 domains[1].dom_name = MSG_ORIG(MSG_SUNW_OST_OSLIB);
 235                 domaincnt = 2;
 236         }
 237 
 238         /*
 239          * If this is a new locale make sure we clean up any old ones.
 240          */
 241         if (rtld_flags & RT_FL_NEWLOCALE) {
 242                 cnt = 0;
 243 
 244                 for (_domain = domains; cnt < domaincnt; _domain++, cnt++) {
 245                         if (_domain->dom_msghdr == 0)
 246                                 continue;
 247 
 248                         if (_domain->dom_msghdr != (Msghdr *)-1)
 249                                 (void) munmap((caddr_t)_domain->dom_msghdr,
 250                                     _domain->dom_msgsz);
 251