MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / SetAdd

Method SetAdd

src/simulate/runtime_string.cpp:269–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267 }
268
269 void SimPolicy_String::SetAdd ( char * a, vec4f b, Context & context, LineInfo * at ) {
270 char ** pA = (char **)a;
271 const char * sA = *pA ? *pA : rts_null;
272 auto la = stringLength(context, sA);
273 const char * sB = to_rts(b);
274 auto lb = stringLength(context, sB);
275 uint32_t commonLength = la + lb;
276 if ( !commonLength ) {
277 // *pA = nullptr; is unnecessary, because its already nullptr
278 return;
279 } else if ( char * sAB = (char * ) context.allocateString(nullptr, commonLength, at) ) {
280 memcpy ( sAB, sA, la );
281 memcpy ( sAB+la, sB, lb+1 );
282 *pA = sAB;
283 context.stringHeap->recognize(sAB);
284 } else {
285 context.throw_out_of_memory(true, commonLength, at);
286 }
287 }
288
289 // helper functions
290

Callers

nothing calls this directly

Calls 5

stringLengthFunction · 0.85
to_rtsFunction · 0.85
allocateStringMethod · 0.80
recognizeMethod · 0.80
throw_out_of_memoryMethod · 0.80

Tested by

no test coverage detected