MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / shrink_to_fit

Method shrink_to_fit

common/SmallString.cpp:95–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void SmallStringBase::shrink_to_fit()
96{
97 const u32 buffer_size = (m_length + 1);
98 if (!m_on_heap || buffer_size == m_buffer_size)
99 return;
100
101 if (m_length == 0)
102 {
103 std::free(m_buffer);
104 m_buffer = nullptr;
105 m_buffer_size = 0;
106 return;
107 }
108
109 char* new_ptr = static_cast<char*>(std::realloc(m_buffer, buffer_size));
110 if (!new_ptr)
111 pxFailRel("Memory allocation failed.");
112
113 m_buffer = new_ptr;
114 m_buffer_size = buffer_size;
115}
116
117std::string_view SmallStringBase::view() const
118{

Callers 1

ReadFileMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected