Crossfire Server, Branches 1.12  R18729
shstr.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _shared_string
 

Macros

#define GATHER(n)
 
#define MAXSTRING   20
 
#define offsetof(type, member)   (int)&(((type *)0)->member)
 
#define PADDING   ((2*sizeof(long)-sizeof(REFCOUNT_TYPE))%sizeof(long))+1
 
#define REFCOUNT_TYPE   int
 
#define SS(x)   ((shared_string *) ((x)-offsetof(shared_string, string)))
 
#define SS_DUMP_TABLE   1
 
#define SS_DUMP_TOTALS   2
 
#define TABLESIZE   4133
 
#define TOPBIT   ((unsigned REFCOUNT_TYPE)1<<(sizeof(REFCOUNT_TYPE)*CHAR_BIT-1))
 

Typedefs

typedef struct _shared_string shared_string
 

Detailed Description

Shared-strings defines.

Definition in file shstr.h.

Macro Definition Documentation

#define GATHER (   n)

Definition at line 60 of file shstr.h.

Referenced by add_refcount(), add_string(), find_string(), free_string(), and hashstr().

#define MAXSTRING   20

This specifies how many characters the hashing routine should look at. You may actually save CPU by increasing this number if the typical string is large.

Definition at line 21 of file shstr.h.

#define offsetof (   type,
  member 
)    (int)&(((type *)0)->member)

The offsetof macro is part of ANSI C, but many compilers lack it, for example "gcc -ansi"

Definition at line 37 of file shstr.h.

Referenced by clear_object(), copy_object(), and get_player().

#define PADDING   ((2*sizeof(long)-sizeof(REFCOUNT_TYPE))%sizeof(long))+1

Definition at line 65 of file shstr.h.

Referenced by new_shared_string().

#define REFCOUNT_TYPE   int

In the unlikely occurence that 16383 references to a string are too few, you can modify the below type to something bigger. (The top bit of "refcount" is used to signify that "u.array" points at the array entry.)

Definition at line 30 of file shstr.h.

#define SS (   x)    ((shared_string *) ((x)-offsetof(shared_string, string)))

SS(string) will return the address of the shared_string struct which contains "string".

Definition at line 44 of file shstr.h.

Referenced by add_refcount(), free_string(), and query_refcount().

#define SS_DUMP_TABLE   1

Definition at line 46 of file shstr.h.

Referenced by command_ssdumptable(), and ss_dump_table().

#define SS_DUMP_TOTALS   2

Definition at line 47 of file shstr.h.

Referenced by command_strings(), and ss_dump_table().

#define TABLESIZE   4133

The size of the shared strings hashtable. This must be smaller than 32767, but 947 ought to be plenty enough.

Definition at line 13 of file shstr.h.

Referenced by hashstr(), init_hash_table(), and ss_dump_table().

#define TOPBIT   ((unsigned REFCOUNT_TYPE)1<<(sizeof(REFCOUNT_TYPE)*CHAR_BIT-1))

Definition at line 63 of file shstr.h.

Referenced by add_string(), free_string(), query_refcount(), and ss_dump_table().

Typedef Documentation

typedef struct _shared_string shared_string

One actual shared string.