--- ray/src/common/savqstr.c 1993/01/27 20:23:49 2.2 +++ ray/src/common/savqstr.c 2003/07/27 22:12:01 2.8 @@ -1,29 +1,69 @@ -/* Copyright (c) 1993 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: savqstr.c,v 2.8 2003/07/27 22:12:01 schorsch Exp $"; #endif +/* + * Save unshared strings. + * + * External symbols declared in standard.h + */ +#include "copyright.h" + +#include + +#include "rterror.h" + + +#if 1 + +char * +savqstr(s) /* save a private string */ +register char *s; +{ + register char *cp; + char *newp; + + for (cp = s; *cp++; ) /* compute strlen()+1 */ + ; + newp = (char *)malloc(cp-s); + if (newp == NULL) { + eputs("out of memory in savqstr"); + quit(1); + } + for (cp = newp; (*cp++ = *s++); ) /* inline strcpy() */ + ; + return(newp); /* return new location */ +} + + +void +freeqstr(s) /* free a private string */ +char *s; +{ + if (s != NULL) + free((void *)s); +} + +#else + /* * Save unshared strings, packing them together into * large blocks to optimize paging in VM environments. */ -#define NULL 0 - -#ifdef BIGMEM +#ifdef SMLMEM #ifndef MINBLOCK -#define MINBLOCK (1<<12) /* minimum allocation block size */ +#define MINBLOCK (1<<10) /* minimum allocation block size */ #endif #ifndef MAXBLOCK -#define MAXBLOCK (1<<16) /* maximum allocation block size */ +#define MAXBLOCK (1<<14) /* maximum allocation block size */ #endif #else #ifndef MINBLOCK -#define MINBLOCK (1<<10) /* minimum allocation block size */ +#define MINBLOCK (1<<12) /* minimum allocation block size */ #endif #ifndef MAXBLOCK -#define MAXBLOCK (1<<14) /* maximum allocation block size */ +#define MAXBLOCK (1<<16) /* maximum allocation block size */ #endif #endif @@ -62,8 +102,11 @@ register char *s; } +void freeqstr(s) /* free a private string (not recommended) */ char *s; { bfree(s, strlen(s)+1); } + +#endif