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

Method reserve

common/SmallString.cpp:58–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void SmallStringBase::reserve(u32 new_reserve)
59{
60 const u32 real_reserve = new_reserve + 1;
61 if (m_buffer_size >= real_reserve)
62 return;
63
64 if (m_on_heap)
65 {
66 char* new_ptr = static_cast<char*>(std::realloc(m_buffer, real_reserve));
67 if (!new_ptr)
68 pxFailRel("Memory allocation failed.");
69
70#ifdef _DEBUG
71 std::memset(new_ptr + m_length, 0, real_reserve - m_length);
72#endif
73 m_buffer = new_ptr;
74 }
75 else
76 {
77 char* new_ptr = static_cast<char*>(std::malloc(real_reserve));
78 if (!new_ptr)
79 pxFailRel("Memory allocation failed.");
80
81 if (m_length > 0)
82 std::memcpy(new_ptr, m_buffer, m_length);
83#ifdef _DEBUG
84 std::memset(new_ptr + m_length, 0, real_reserve - m_length);
85#else
86 new_ptr[m_length] = 0;
87#endif
88 m_buffer = new_ptr;
89 m_on_heap = true;
90 }
91
92 m_buffer_size = new_reserve;
93}
94
95void SmallStringBase::shrink_to_fit()
96{

Callers 15

HTTPStatusCallbackMethod · 0.45
DecodeHexFunction · 0.45
EllipsiseFunction · 0.45
WriteToConsoleMethod · 0.45
PathAppendStringFunction · 0.45
SanitizeFileNameMethod · 0.45
RealPathMethod · 0.45
CanonicalizeMethod · 0.45
AppendDirectoryMethod · 0.45
CombineMethod · 0.45
URLEncodeMethod · 0.45
URLDecodeMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected