MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxAdornStringC

Function fxAdornStringC

xs/sources/xsAll.c:47–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45static void fxBufferName(txString dst, txString src, txSize size);
46
47txString fxAdornStringC(txMachine* the, txString prefix, txSlot* string, txString suffix)
48{
49 txSize stringSize = mxStringLength(string->value.string);
50 txSize prefixSize = prefix ? mxStringLength(prefix) : 0;
51 txSize suffixSize = suffix ? mxStringLength(suffix) : 0;
52 txSize resultSize = fxAddChunkSizes(the, fxAddChunkSizes(the, fxAddChunkSizes(the, stringSize, prefixSize), suffixSize), 1);
53 txString result = (txString)fxNewChunk(the, resultSize);
54 if (prefix && prefixSize)
55 c_memcpy(result, prefix, prefixSize);
56 if (stringSize)
57 c_memcpy(result + prefixSize, string->value.string, stringSize);
58 if (suffix && suffixSize)
59 c_memcpy(result + prefixSize + stringSize, suffix, suffixSize);
60 result[prefixSize + stringSize + suffixSize] = 0;
61 string->kind = XS_STRING_KIND;
62 string->value.string = result;
63 return result;
64}
65
66txSlot* fxArgToCallback(txMachine* the, txInteger argi)
67{

Callers 2

fxNewFunctionNameFunction · 0.85
fxNewFunctionNameFunction · 0.85

Calls 1

fxNewChunkFunction · 0.85

Tested by

no test coverage detected