MCPcopy Create free account
hub / github.com/F-Stack/f-stack / createstrobj

Function createstrobj

freebsd/contrib/openzfs/module/lua/lstring.c:97–111  ·  view source on GitHub ↗

** creates a new string object */

Source from the content-addressed store, hash-verified

95** creates a new string object
96*/
97static TString *createstrobj (lua_State *L, const char *str, size_t l,
98 int tag, unsigned int h, GCObject **list) {
99 TString *ts;
100 char *sbuf;
101 size_t totalsize; /* total size of TString object */
102 totalsize = sizeof(TString) + ((l + 1) * sizeof(char));
103 ts = &luaC_newobj(L, tag, totalsize, list, 0)->ts;
104 ts->tsv.len = l;
105 ts->tsv.hash = h;
106 ts->tsv.extra = 0;
107 sbuf = (char *)(TString *)(ts + 1);
108 memcpy(sbuf, str, l*sizeof(char));
109 sbuf[l] = '\0'; /* ending 0 */
110 return ts;
111}
112
113
114/*

Callers 2

newshrstrFunction · 0.85
luaS_newlstrFunction · 0.85

Calls 2

luaC_newobjFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected