MCPcopy Create free account
hub / github.com/beefytech/Beef / concat

Function concat

IDEHelper/VSSupport.cpp:197–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197wchar_t *concat(wchar_t *a, wchar_t *b, wchar_t *c = nullptr, wchar_t *d = nullptr) {
198 // Concatenate up to 4 wide strings together. Allocated with malloc.
199 // If you don't like that, use a programming language that actually
200 // helps you with using custom allocators. Or just edit the code.
201
202 auto len_a = wcslen(a);
203 auto len_b = wcslen(b);
204
205 auto len_c = 0;
206 if (c) len_c = (int)wcslen(c);
207
208 auto len_d = 0;
209 if (d) len_d = (int)wcslen(d);
210
211 wchar_t *result = (wchar_t *)malloc((len_a + len_b + len_c + len_d + 1) * 2);
212 memcpy(result, a, len_a * 2);
213 memcpy(result + len_a, b, len_b * 2);
214
215 if (c) memcpy(result + len_a + len_b, c, len_c * 2);
216 if (d) memcpy(result + len_a + len_b + len_c, d, len_d * 2);
217
218 result[len_a + len_b + len_c + len_d] = 0;
219
220 return result;
221}
222
223typedef void(*Visit_Proc_W)(wchar_t *short_name, wchar_t *full_name, Version_Data *data);
224bool visit_files_w(wchar_t *dir_name, Version_Data *data, Visit_Proc_W proc) {

Calls 1

mallocFunction · 0.50

Tested by

no test coverage detected