ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/savestr.c
(Generate patch)

Comparing ray/src/common/savestr.c (file contents):
Revision 2.10 by greg, Thu Mar 4 16:34:34 2004 UTC vs.
Revision 2.11 by greg, Sun Apr 9 21:33:24 2017 UTC

# Line 50 | Line 50 | static S_HEAD  *stab[NHASH];
50   char *
51   savestr(char *str)                              /* save a string */
52   {
53 <        register int  hval;
54 <        register S_HEAD  *sp;
53 >        int  hval;
54 >        S_HEAD  *sp;
55  
56          if (str == NULL)
57                  return(NULL);
58 +        if (!*str)
59 +                return "";
60          hval = hash(str);
61          for (sp = stab[hval]; sp != NULL; sp = sp->next)
62                  if (!strcmp(str, string(sp))) {
# Line 77 | Line 79 | void
79   freestr(char *s)                                /* free a string */
80   {
81          int  hval;
82 <        register S_HEAD  *spl, *sp;
82 >        S_HEAD  *spl, *sp;
83  
84 <        if (s == NULL)
84 >        if (s == NULL || !*s)
85                  return;
86          hval = hash(s);
87          for (spl = NULL, sp = stab[hval]; sp != NULL; spl = sp, sp = sp->next)
# Line 97 | Line 99 | freestr(char *s)                               /* free a string */
99  
100  
101   int
102 < shash(register char  *s)
102 > shash(char *s)
103   {
104 <        register int  h = 0;
104 >        int  h = 0;
105  
106          while (*s)
107                  h = (h<<1 & 0x7fff) ^ (*s++ & 0xff);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines