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.12 by greg, Sat Dec 28 18:05:14 2019 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines