fix cr/lfs and remove trailing whitespaces...
[supertux.git] / src / squirrel / squirrel / sqstring.h
1 /*      see copyright notice in squirrel.h */
2 #ifndef _SQSTRING_H_
3 #define _SQSTRING_H_
4
5 inline SQHash _hashstr (const SQChar *s, size_t l)
6 {
7                 SQHash h = (SQHash)l;  /* seed */
8                 size_t step = (l>>5)|1;  /* if string is too long, don't hash all its chars */
9                 for (; l>=step; l-=step)
10                         h = h ^ ((h<<5)+(h>>2)+(unsigned short)*(s++));
11                 return h;
12 }
13
14 struct SQString : public SQRefCounted
15 {
16         SQString(){}
17         ~SQString(){}
18 public:
19         static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 );
20         SQInteger Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
21         void Release();
22         SQSharedState *_sharedstate;
23         SQString *_next; //chain for the string table
24         SQInteger _len;
25         SQHash _hash;
26         SQChar _val[1];
27 };
28
29
30
31 #endif //_SQSTRING_H_