|
|
1 | #ifndef SHSTR_H__ |
|
|
2 | #define SHSTR_H__ |
|
|
3 | |
|
|
4 | //// OLD STUFF |
|
|
5 | |
1 | /* The size of the shared strings hashtable. This must be smaller than |
6 | /* The size of the shared strings hashtable. This must be smaller than |
2 | * 32767, but 947 ought to be plenty enough. |
7 | * 32767, but 947 ought to be plenty enough. |
3 | */ |
8 | */ |
4 | #define TABLESIZE 4133 |
9 | #define TABLESIZE 4133 |
5 | |
10 | |
… | |
… | |
52 | |
57 | |
53 | #define PADDING ((2 * sizeof(long) - sizeof(REFCOUNT_TYPE)) % sizeof(long)) + 1 |
58 | #define PADDING ((2 * sizeof(long) - sizeof(REFCOUNT_TYPE)) % sizeof(long)) + 1 |
54 | |
59 | |
55 | typedef struct _shared_string { |
60 | typedef struct _shared_string { |
56 | union { |
61 | union { |
57 | struct _shared_string **array; |
62 | struct _shared_string **array; |
58 | struct _shared_string *previous; |
63 | struct _shared_string *previous; |
59 | } u; |
64 | } u; |
60 | struct _shared_string *next; |
65 | struct _shared_string *next; |
61 | /* The top bit of "refcount" is used to signify that "u.array" points |
66 | /* The top bit of "refcount" is used to signify that "u.array" points |
62 | * at the array entry. |
67 | * at the array entry. |
63 | */ |
68 | */ |
… | |
… | |
66 | * the padding when allocating memory. We assume here that |
71 | * the padding when allocating memory. We assume here that |
67 | * sizeof(long) is a good boundary. |
72 | * sizeof(long) is a good boundary. |
68 | */ |
73 | */ |
69 | char string[PADDING]; |
74 | char string[PADDING]; |
70 | } shared_string; |
75 | } shared_string; |
|
|
76 | |
|
|
77 | extern void init_hash_table(void); |
|
|
78 | extern const char *add_string(const char *str); |
|
|
79 | extern const char *add_refcount(const char *str); |
|
|
80 | extern int query_refcount(const char *str); |
|
|
81 | extern const char *find_string(const char *str); |
|
|
82 | extern void free_string(const char *str); |
|
|
83 | extern void ss_dump_statistics(void); |
|
|
84 | extern const char *ss_dump_table(int what); |
|
|
85 | extern int buf_overflow(const char *buf1, const char *buf2, int bufsize); |
|
|
86 | |
|
|
87 | //// NEW STUFF |
|
|
88 | |
|
|
89 | #if 0 |
|
|
90 | struct shstr |
|
|
91 | { |
|
|
92 | const char *s; |
|
|
93 | operator const char *() const { return s; }; |
|
|
94 | shstr &operator =(const char *str) { s = str; }; |
|
|
95 | }; |
|
|
96 | #else |
|
|
97 | typedef const char *shstr; |
|
|
98 | #endif |
|
|
99 | |
|
|
100 | #endif |
|
|
101 | |