MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / __init

Method __init

system/lib/libcxx/src/string.cpp:46–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45template <class _CharT, class _Traits, class _Allocator>
46void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) {
47 if (__libcpp_is_constant_evaluated())
48 __rep_ = __rep();
49 if (__reserve > max_size())
50 __throw_length_error();
51 pointer __p;
52 if (__fits_in_sso(__reserve)) {
53 __set_short_size(__sz);
54 __p = __get_short_pointer();
55 } else {
56 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1);
57 __p = __allocation.ptr;
58 __begin_lifetime(__p, __allocation.count);
59 __set_long_pointer(__p);
60 __set_long_cap(__allocation.count);
61 __set_long_size(__sz);
62 }
63 traits_type::copy(std::__to_address(__p), __s, __sz);
64 traits_type::assign(__p[__sz], value_type());
65 __annotate_new(__sz);
66}
67
68# define STRING_LEGACY_API(CharT) \
69 template _LIBCPP_EXPORTED_FROM_ABI void basic_string<CharT>::__init(const value_type*, size_type, size_type)

Callers

nothing calls this directly

Calls 7

__throw_length_errorFunction · 0.85
__allocate_at_leastFunction · 0.85
__to_addressFunction · 0.85
value_typeClass · 0.85
max_sizeFunction · 0.70
copyFunction · 0.50
assignFunction · 0.50

Tested by

no test coverage detected