Crossfire Server, Branch 1.12
R12190
|
00001 00006 #ifndef SHSTR_H 00007 #define SHSTR_H 00008 00013 #define TABLESIZE 4133 00014 00020 #ifndef MAXSTRING 00021 #define MAXSTRING 20 00022 #endif 00023 00030 #define REFCOUNT_TYPE int 00031 00036 #if !defined(offsetof) 00037 #define offsetof(type, member) (int)&(((type *)0)->member) 00038 #endif 00039 00044 #define SS(x) ((shared_string *) ((x)-offsetof(shared_string, string))) 00045 00046 #define SS_DUMP_TABLE 1 00047 #define SS_DUMP_TOTALS 2 00048 00049 #ifdef SS_STATISTICS 00050 00051 static struct statistics { 00052 int calls; 00053 int hashed; 00054 int strcmps; 00055 int search; 00056 int linked; 00057 } add_stats, add_ref_stats, free_stats, find_stats, hash_stats; 00058 #define GATHER(n) (++n) 00059 #else /* !SS_STATISTICS */ 00060 #define GATHER(n) 00061 #endif /* SS_STATISTICS */ 00062 00063 #define TOPBIT ((unsigned REFCOUNT_TYPE)1<<(sizeof(REFCOUNT_TYPE)*CHAR_BIT-1)) 00064 00065 #define PADDING ((2*sizeof(long)-sizeof(REFCOUNT_TYPE))%sizeof(long))+1 00066 00070 typedef struct _shared_string { 00071 union { 00072 struct _shared_string **array; 00073 struct _shared_string *previous; 00074 } u; 00075 struct _shared_string *next; 00076 /* The top bit of "refcount" is used to signify that "u.array" points 00077 * at the array entry. 00078 */ 00079 unsigned REFCOUNT_TYPE refcount; 00080 /* Padding will be unused memory, since we can't know how large 00081 * the padding when allocating memory. We assume here that 00082 * sizeof(long) is a good boundary. 00083 */ 00084 char string[PADDING]; 00085 } shared_string; 00086 00087 #endif /* SHSTR_H */