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.4 by greg, Thu Sep 23 12:15:21 1993 UTC vs.
Revision 2.10 by greg, Thu Mar 4 16:34:34 2004 UTC

# Line 1 | Line 1
1 /* Copyright 1988 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  savestr.c - routines for efficient string storage.
6   *
# Line 12 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   *      All strings must be null-terminated.  There is
10   *  no imposed length limit.
11   *      Strings stored with savestr(s) can be equated
12 < *  reliably using their pointer values.  A tailored version
16 < *  of strcmp(s1,s2) is included.
12 > *  reliably using their pointer values.
13   *      Calls to savestr(s) and freestr(s) should be
14   *  balanced (obviously).  The last call to freestr(s)
15   *  frees memory associated with the string; it should
16   *  never be referenced again.
17   *
18 < *     5/14/87
18 > *  External symbols declared in standard.h
19   */
20  
21 + #include "copyright.h"
22 +
23 + #include <string.h>
24 + #include <stdlib.h>
25 +
26 + #include "rtmisc.h"
27 + #include "rterror.h"
28 + #include "rtio.h"
29 +
30   #ifndef  NHASH
31 < #define  NHASH          509             /* hash table size (prime!) */
31 > #define  NHASH          2039            /* hash table size (prime!) */
32   #endif
33  
34   typedef struct s_head {
# Line 35 | Line 40 | static S_HEAD  *stab[NHASH];
40  
41   #define  hash(s)        (shash(s)%NHASH)
42  
38 extern char  *savestr(), *strcpy(), *malloc();
39
40 #define  NULL           0
41
43   #define  string(sp)     ((char *)((sp)+1))
44  
45   #define  salloc(str)    (S_HEAD *)malloc(sizeof(S_HEAD)+1+strlen(str))
46  
47 < #define  sfree(sp)      free((char *)(sp))
47 > #define  sfree(sp)      free((void *)(sp))
48  
49  
50   char *
51 < savestr(str)                            /* save a string */
51 < char  *str;
51 > savestr(char *str)                              /* save a string */
52   {
53          register int  hval;
54          register S_HEAD  *sp;
# Line 73 | Line 73 | char  *str;
73   }
74  
75  
76 < freestr(s)                              /* free a string */
77 < char  *s;
76 > void
77 > freestr(char *s)                                /* free a string */
78   {
79          int  hval;
80          register S_HEAD  *spl, *sp;
# Line 97 | Line 97 | char  *s;
97  
98  
99   int
100 < shash(s)
101 < register char  *s;
100 > shash(register char  *s)
101   {
102          register int  h = 0;
103  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines