MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / grow

Method grow

src/isql/Extender.cpp:88–109  ·  view source on GitHub ↗

Unlike alloc() and allocFill(), this is not a destructive operation. If the requested size is not bigger than the existing one, nothing happens and the insertion point remains in its current position. Otherwise, reallocation happens and the old contents are copied into the new buffer. Notice only getUsed() bytes are copied. This means a fill pattern will not be preserved. The insertion point is up

Source from the content-addressed store, hash-verified

86// to the same position in the string where it was before growing the buffer.
87// The position at the insertion point is initialized to zero to aid in debugging.
88void Extender::grow(size_t n)
89{
90 if (m_pos == m_buf)
91 {
92 // We don't have data to preserve, go faster.
93 alloc(n);
94 return;
95 }
96
97 if (m_size < n)
98 {
99 const size_t old_pos = getUsed();
100 char* const old_buf = m_buf;
101
102 m_buf = FB_NEW char[m_size = n];
103 memcpy(m_buf, old_buf, old_pos); // Copy only the used bytes.
104 m_pos = m_buf + old_pos; // Reposition the current insertion point.
105 m_pos[0] = 0; // Same as alloc().
106
107 delete[] old_buf;
108 }
109}
110

Callers 15

rem_fmtMethod · 0.45
RrqMethod · 0.45
setHandleMethod · 0.45
var_infoFunction · 0.45
parseMetadataMethod · 0.45
transformStringMethod · 0.45
executeMethod · 0.45
parseMethod · 0.45
lookupCollationMethod · 0.45
StatementMethod · 0.45
getRequestMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected