| 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 |
nothing calls this directly
no test coverage detected