File tree Expand file tree Collapse file tree 1 file changed +6
-19
lines changed Expand file tree Collapse file tree 1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change 40
40
#include " SwiftObject.h"
41
41
#endif
42
42
43
- #if defined(_WIN32)
44
- #include < stdarg.h>
45
-
46
- namespace {
47
- char *strndup (const char *s, size_t n) {
48
- size_t length = std::min (strlen (s), n);
49
-
50
- char *buffer = reinterpret_cast <char *>(malloc (length + 1 ));
51
- if (buffer == nullptr )
52
- return buffer;
53
-
54
- strncpy (buffer, s, length);
55
- buffer[length] = ' \0 ' ;
56
- return buffer;
57
- }
58
- }
59
- #endif
60
-
61
43
using namespace swift ;
62
44
63
45
namespace {
@@ -261,7 +243,12 @@ struct TupleImpl : ReflectionMirrorImpl {
261
243
262
244
// If we have a label, create it.
263
245
if (labels && space && labels != space) {
264
- *outName = strndup (labels, space - labels);
246
+ size_t labelLen = space - labels;
247
+ char *label = (char *)malloc (labelLen + 1 );
248
+ memcpy (label, labels, labelLen);
249
+ label[labelLen] = ' \0 ' ; // 0-terminate the string
250
+
251
+ *outName = label;
265
252
hasLabel = true ;
266
253
}
267
254
}
You can’t perform that action at this time.
0 commit comments