1 |
– |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
+ |
/* |
5 |
+ |
* Save unshared strings. |
6 |
+ |
* |
7 |
+ |
* External symbols declared in standard.h |
8 |
+ |
*/ |
9 |
|
|
10 |
+ |
#include "copyright.h" |
11 |
+ |
|
12 |
+ |
#include <stdlib.h> |
13 |
+ |
|
14 |
+ |
#include "rtio.h" |
15 |
+ |
#include "rterror.h" |
16 |
+ |
|
17 |
+ |
|
18 |
+ |
#if 1 |
19 |
+ |
|
20 |
+ |
char * |
21 |
+ |
savqstr(char *s) /* save a private string */ |
22 |
+ |
{ |
23 |
+ |
char *cp; |
24 |
+ |
char *newp; |
25 |
+ |
|
26 |
+ |
for (cp = s; *cp++; ) /* compute strlen()+1 */ |
27 |
+ |
; |
28 |
+ |
newp = (char *)malloc(cp-s); |
29 |
+ |
if (newp == NULL) { |
30 |
+ |
eputs("out of memory in savqstr"); |
31 |
+ |
quit(1); |
32 |
+ |
} |
33 |
+ |
for (cp = newp; (*cp++ = *s++); ) /* inline strcpy() */ |
34 |
+ |
; |
35 |
+ |
return(newp); /* return new location */ |
36 |
+ |
} |
37 |
+ |
|
38 |
+ |
|
39 |
+ |
void |
40 |
+ |
freeqstr(char *s) /* free a private string */ |
41 |
+ |
{ |
42 |
+ |
if (s != NULL) |
43 |
+ |
free((void *)s); |
44 |
+ |
} |
45 |
+ |
|
46 |
+ |
#else |
47 |
+ |
|
48 |
|
/* |
49 |
|
* Save unshared strings, packing them together into |
50 |
|
* large blocks to optimize paging in VM environments. |
51 |
|
*/ |
52 |
|
|
53 |
< |
#define NULL 0 |
53 |
> |
#include "rtmisc.h" |
54 |
|
|
55 |
< |
#ifdef BIGMEM |
55 |
> |
#ifdef SMLMEM |
56 |
|
#ifndef MINBLOCK |
57 |
< |
#define MINBLOCK (1<<12) /* minimum allocation block size */ |
57 |
> |
#define MINBLOCK (1<<10) /* minimum allocation block size */ |
58 |
|
#endif |
59 |
|
#ifndef MAXBLOCK |
60 |
< |
#define MAXBLOCK (1<<16) /* maximum allocation block size */ |
60 |
> |
#define MAXBLOCK (1<<14) /* maximum allocation block size */ |
61 |
|
#endif |
62 |
|
#else |
63 |
|
#ifndef MINBLOCK |
64 |
< |
#define MINBLOCK (1<<10) /* minimum allocation block size */ |
64 |
> |
#define MINBLOCK (1<<12) /* minimum allocation block size */ |
65 |
|
#endif |
66 |
|
#ifndef MAXBLOCK |
67 |
< |
#define MAXBLOCK (1<<14) /* maximum allocation block size */ |
67 |
> |
#define MAXBLOCK (1<<16) /* maximum allocation block size */ |
68 |
|
#endif |
69 |
|
#endif |
70 |
|
|
30 |
– |
extern char *bmalloc(); |
71 |
|
|
32 |
– |
|
72 |
|
char * |
73 |
< |
savqstr(s) /* save a private string */ |
35 |
< |
register char *s; |
73 |
> |
savqstr(char *s) /* save a private string */ |
74 |
|
{ |
75 |
|
static char *curp = NULL; /* allocated memory pointer */ |
76 |
|
static unsigned nrem = 0; /* bytes remaining in block */ |
77 |
|
static unsigned nextalloc = MINBLOCK; /* next block size */ |
78 |
< |
register char *cp; |
79 |
< |
register unsigned n; |
78 |
> |
char *cp; |
79 |
> |
unsigned n; |
80 |
|
|
81 |
|
for (cp = s; *cp++; ) /* compute strlen()+1 */ |
82 |
|
; |
100 |
|
} |
101 |
|
|
102 |
|
|
103 |
< |
freeqstr(s) /* free a private string (not recommended) */ |
104 |
< |
char *s; |
103 |
> |
void |
104 |
> |
freeqstr(char *s) /* free a private string (not recommended) */ |
105 |
|
{ |
106 |
|
bfree(s, strlen(s)+1); |
107 |
|
} |
108 |
+ |
|
109 |
+ |
#endif |