CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
lstring.h-Dateireferenz
#include "lgc.h"
#include "lobject.h"
#include "lstate.h"
+ Include-Abhängigkeitsdiagramm für lstring.h:
+ Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define sizestring(s)   (sizeof(union TString)+((s)->len+1)*sizeof(char))
 
#define sizeudata(u)   (sizeof(union Udata)+(u)->len)
 
#define luaS_new(L, s)   (luaS_newlstr(L, s, strlen(s)))
 
#define luaS_newliteral(L, s)
 
#define luaS_fix(s)   l_setbit((s)->tsv.marked, FIXEDBIT)
 

Funktionen

LUAI_FUNC void luaS_resize (lua_State *L, int newsize)
 
LUAI_FUNC UdataluaS_newudata (lua_State *L, size_t s, Table *e)
 
LUAI_FUNC TStringluaS_newlstr (lua_State *L, const char *str, size_t l)
 

Makro-Dokumentation

#define luaS_fix (   s)    l_setbit((s)->tsv.marked, FIXEDBIT)

Definiert in Zeile 24 der Datei lstring.h.

#define luaS_new (   L,
  s 
)    (luaS_newlstr(L, s, strlen(s)))

Definiert in Zeile 20 der Datei lstring.h.

#define luaS_newliteral (   L,
  s 
)
Wert:
(luaS_newlstr(L, "" s, \
(sizeof(s)/sizeof(char))-1))

Definiert in Zeile 21 der Datei lstring.h.

#define sizestring (   s)    (sizeof(union TString)+((s)->len+1)*sizeof(char))

Definiert in Zeile 16 der Datei lstring.h.

#define sizeudata (   u)    (sizeof(union Udata)+(u)->len)

Definiert in Zeile 18 der Datei lstring.h.

Dokumentation der Funktionen

LUAI_FUNC TString* luaS_newlstr ( lua_State L,
const char *  str,
size_t  l 
)

Definiert in Zeile 75 der Datei lstring.c.

75  {
76  GCObject *o;
77  unsigned int h = cast(unsigned int, l); /* seed */
78  size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
79  size_t l1;
80  for (l1=l; l1>=step; l1-=step) /* compute hash */
81  h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
82  for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
83  o != NULL;
84  o = o->gch.next) {
85  TString *ts = rawgco2ts(o);
86  if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
87  /* string may be dead */
88  if (isdead(G(L), o)) changewhite(o);
89  return ts;
90  }
91  }
92  return newlstr(L, str, l, h); /* not found */
93 }
LUAI_FUNC Udata* luaS_newudata ( lua_State L,
size_t  s,
Table e 
)

Definiert in Zeile 96 der Datei lstring.c.

96  {
97  Udata *u;
98  if (s > MAX_SIZET - sizeof(Udata))
99  luaM_toobig(L);
100  u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
101  u->uv.marked = luaC_white(G(L)); /* is not finalized */
102  u->uv.tt = LUA_TUSERDATA;
103  u->uv.len = s;
104  u->uv.metatable = NULL;
105  u->uv.env = e;
106  /* chain it on udata list (after main thread) */
107  u->uv.next = G(L)->mainthread->next;
108  G(L)->mainthread->next = obj2gco(u);
109  return u;
110 }
LUAI_FUNC void luaS_resize ( lua_State L,
int  newsize 
)

Definiert in Zeile 22 der Datei lstring.c.

22  {
23  GCObject **newhash;
24  stringtable *tb;
25  int i;
26  if (G(L)->gcstate == GCSsweepstring)
27  return; /* cannot resize during GC traverse */
28  newhash = luaM_newvector(L, newsize, GCObject *);
29  tb = &G(L)->strt;
30  for (i=0; i<newsize; i++) newhash[i] = NULL;
31  /* rehash */
32  for (i=0; i<tb->size; i++) {
33  GCObject *p = tb->hash[i];
34  while (p) { /* for each node in the list */
35  GCObject *next = p->gch.next; /* save next */
36  unsigned int h = gco2ts(p)->hash;
37  int h1 = lmod(h, newsize); /* new position */
38  lua_assert(cast_int(h%newsize) == lmod(h, newsize));
39  p->gch.next = newhash[h1]; /* chain it */
40  newhash[h1] = p;
41  p = next;
42  }
43  }
44  luaM_freearray(L, tb->hash, tb->size, TString *);
45  tb->size = newsize;
46  tb->hash = newhash;
47 }