--- ray/src/common/savestr.c 1993/09/23 12:15:21 2.4 +++ ray/src/common/savestr.c 2004/03/04 16:34:34 2.10 @@ -1,9 +1,6 @@ -/* Copyright 1988 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: savestr.c,v 2.10 2004/03/04 16:34:34 greg Exp $"; #endif - /* * savestr.c - routines for efficient string storage. * @@ -12,18 +9,26 @@ static char SCCSid[] = "$SunId$ LBL"; * All strings must be null-terminated. There is * no imposed length limit. * Strings stored with savestr(s) can be equated - * reliably using their pointer values. A tailored version - * of strcmp(s1,s2) is included. + * reliably using their pointer values. * Calls to savestr(s) and freestr(s) should be * balanced (obviously). The last call to freestr(s) * frees memory associated with the string; it should * never be referenced again. * - * 5/14/87 + * External symbols declared in standard.h */ +#include "copyright.h" + +#include +#include + +#include "rtmisc.h" +#include "rterror.h" +#include "rtio.h" + #ifndef NHASH -#define NHASH 509 /* hash table size (prime!) */ +#define NHASH 2039 /* hash table size (prime!) */ #endif typedef struct s_head { @@ -35,20 +40,15 @@ static S_HEAD *stab[NHASH]; #define hash(s) (shash(s)%NHASH) -extern char *savestr(), *strcpy(), *malloc(); - -#define NULL 0 - #define string(sp) ((char *)((sp)+1)) #define salloc(str) (S_HEAD *)malloc(sizeof(S_HEAD)+1+strlen(str)) -#define sfree(sp) free((char *)(sp)) +#define sfree(sp) free((void *)(sp)) char * -savestr(str) /* save a string */ -char *str; +savestr(char *str) /* save a string */ { register int hval; register S_HEAD *sp; @@ -73,8 +73,8 @@ char *str; } -freestr(s) /* free a string */ -char *s; +void +freestr(char *s) /* free a string */ { int hval; register S_HEAD *spl, *sp; @@ -97,8 +97,7 @@ char *s; int -shash(s) -register char *s; +shash(register char *s) { register int h = 0;