MCPcopy Create free account
hub / github.com/aardappel/treesheets / ResizeString

Method ResizeString

lobster/src/vm.cpp:275–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275LString *VM::ResizeString(LString *s, intp size, int c, bool back) {
276 auto ns = NewString(size);
277 auto sdest = (char *)ns->data();
278 auto cdest = sdest;
279 auto remain = size - s->len;
280 if (back) sdest += remain;
281 else cdest += s->len;
282 memcpy(sdest, s->data(), s->len);
283 memset(cdest, c, remain);
284 s->Dec(*this);
285 return ns;
286}
287
288// This function is now way less important than it was when the language was still dynamically
289// typed. But ok to leave it as-is for "index out of range" and other errors that are still dynamic.

Callers 2

AddFileFunction · 0.80
WriteMemFunction · 0.80

Calls 2

DecMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected