File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -334,9 +334,9 @@ String cpp::encoding::Utf8::decode(const cpp::marshal::View<uint8_t>& buffer)
334334 return Ascii::decode (buffer);
335335 }
336336#if defined(HX_SMART_STRINGS)
337- auto estimated_length = buffer.length ;
337+ auto estimated_length = buffer.length * sizeof ( char16_t ) ;
338338
339- auto temp = ::String::allocChar16Ptr (estimated_length);
339+ auto temp = ::hx::InternalNew (estimated_length, false );
340340 auto output = View<char16_t >(temp, estimated_length).reinterpret <uint8_t >();
341341 int64_t k = 0 ;
342342 int64_t i = 0 ;
@@ -350,9 +350,10 @@ String cpp::encoding::Utf8::decode(const cpp::marshal::View<uint8_t>& buffer)
350350 }
351351
352352 auto chars = static_cast <int >(k / sizeof (char16_t ));
353- auto exact = ::String::allocChar16Ptr (chars);
354353
355- std::memcpy (exact, temp, k);
354+ auto exact = static_cast <char16_t *>(::hx::InternalRealloc (estimated_length, temp, k + sizeof (char16_t )));
355+ ((unsigned int *)exact)[-1 ] |= HX_GC_STRING_CHAR16_T;
356+ exact[chars] = 0 ;
356357
357358 return String (exact, chars);
358359#else
You can’t perform that action at this time.
0 commit comments