--- ray/src/common/savestr.c 1992/11/21 21:46:59 2.3 +++ ray/src/common/savestr.c 2003/06/07 12:50:20 2.7 @@ -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.7 2003/06/07 12:50:20 schorsch Exp $"; #endif - /* * savestr.c - routines for efficient string storage. * @@ -12,16 +9,22 @@ 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 "standard.h" + #ifndef NHASH #define NHASH 509 /* hash table size (prime!) */ #endif @@ -35,15 +38,11 @@ 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 * @@ -73,6 +72,7 @@ char *str; } +void freestr(s) /* free a string */ char *s; { @@ -103,6 +103,6 @@ register char *s; register int h = 0; while (*s) - h = (h<<1 & 0x7fff) ^ *s++; + h = (h<<1 & 0x7fff) ^ (*s++ & 0xff); return(h); }