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