Crossfire Server, Branches 1.12  R18729
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 typedef 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];
86 
87 #endif /* SHSTR_H */
union _shared_string::@3 u
struct Statistics statistics
Definition: init.c:119
struct _shared_string * previous
Definition: shstr.h:73
struct _shared_string * next
Definition: shstr.h:75
struct _shared_string ** array
Definition: shstr.h:72
unsigned REFCOUNT_TYPE refcount
Definition: shstr.h:79
#define PADDING
Definition: shstr.h:65
struct _shared_string shared_string
#define REFCOUNT_TYPE
Definition: shstr.h:30