Crossfire Server, Trunk
shstr.h
Go to the documentation of this file.
1 
6 #ifndef SHSTR_H
7 #define SHSTR_H
8 
13 #define TABLESIZE 4133
14 
20 #ifndef MAXSTRING
21 #define MAXSTRING 20
22 #endif
23 
30 #define REFCOUNT_TYPE int
31 
36 #if !defined(offsetof)
37 #define offsetof(type, member) (int)&(((type *)0)->member)
38 #endif
39 
44 #define SS(x) ((shared_string *) ((x)-offsetof(shared_string, string)))
45 
46 #define SS_DUMP_TABLE 1
47 #define SS_DUMP_TOTALS 2
48 
49 #ifdef SS_STATISTICS
50 
51 static struct statistics {
52  int calls;
53  int hashed;
54  int strcmps;
55  int search;
56  int linked;
57 } add_stats, add_ref_stats, free_stats, find_stats, hash_stats;
58 #define GATHER(n) (++n)
59 #else /* !SS_STATISTICS */
60 #define GATHER(n)
61 #endif /* SS_STATISTICS */
62 
63 #define TOPBIT ((unsigned REFCOUNT_TYPE)1<<(sizeof(REFCOUNT_TYPE)*CHAR_BIT-1))
64 
65 #define PADDING ((2*sizeof(long)-sizeof(REFCOUNT_TYPE))%sizeof(long))+1
66 
70 struct shared_string {
71  union {
74  } u;
76  /* The top bit of "refcount" is used to signify that "u.array" points
77  * at the array entry.
78  */
80  /* Padding will be unused memory, since we can't know how large
81  * the padding when allocating memory. We assume here that
82  * sizeof(long) is a good boundary.
83  */
84  char string[PADDING];
85 };
86 
87 #endif /* SHSTR_H */
REFCOUNT_TYPE
#define REFCOUNT_TYPE
Definition: shstr.h:30
statistics
struct Statistics statistics
Definition: init.cpp:233
shared_string::previous
shared_string * previous
Definition: shstr.h:73
shared_string::refcount
unsigned REFCOUNT_TYPE refcount
Definition: shstr.h:79
shared_string::array
shared_string ** array
Definition: shstr.h:72
shared_string::next
shared_string * next
Definition: shstr.h:75
shared_string::u
union shared_string::@7 u
PADDING
#define PADDING
Definition: shstr.h:65
shared_string
Definition: shstr.h:70