浏览代码

`getstr' now gives const char *

Roberto Ierusalimschy 23 年之前
父节点
当前提交
d3651c1d88
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      lstring.c

+ 2 - 2
lstring.c

@@ -53,8 +53,8 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, lu_hash h) {
   ts->tsv.len = l;
   ts->tsv.len = l;
   ts->tsv.hash = h;
   ts->tsv.hash = h;
   ts->tsv.marked = 0;
   ts->tsv.marked = 0;
-  memcpy(getstr(ts), str, l*sizeof(char));
-  getstr(ts)[l] = '\0';  /* ending 0 */
+  memcpy(ts+1, str, l*sizeof(char));
+  ((char *)(ts+1))[l] = '\0';  /* ending 0 */
   tb = &G(L)->strt;
   tb = &G(L)->strt;
   h = lmod(h, tb->size);
   h = lmod(h, tb->size);
   ts->tsv.nexthash = tb->hash[h];  /* chain new entry */
   ts->tsv.nexthash = tb->hash[h];  /* chain new entry */