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

Method append

src/isql/Extender.cpp:61–78  ·  view source on GitHub ↗

Append to the string. Note second parameter is the size, not the length. This means that a null terminator is not added unless the input contains it. If there's already a null terminator, it's not discarded before appending! If there's space used, a newline is optionally used as separator between the existing content and the new input. The internal buffer is not grown; the input will be truncated.

Source from the content-addressed store, hash-verified

59// The internal buffer is not grown; the input will be truncated.
60// The amount of written bytes (the ones that fit) is returned.
61size_t Extender::append(const char* s, size_t s_size, bool newline)
62{
63 if (m_pos >= m_buf + m_size) // Full buffer?
64 return 0;
65
66 const size_t extra = m_buf < m_pos && newline ? 1 : 0;
67
68 if (m_pos + s_size + extra > m_buf + m_size) // Adjust the argument, truncating it.
69 s_size = m_buf + m_size - m_pos - extra;
70
71 // Do not append newline if there's nothing before or the caller doesn't want it.
72 if (extra)
73 *m_pos++ = '\n';
74
75 memcpy(m_pos, s, s_size);
76 m_pos += s_size;
77 return s_size + extra;
78}
79
80// Unlike alloc() and allocFill(), this is not a destructive operation.
81// If the requested size is not bigger than the existing one, nothing happens and

Callers 15

_MakeRangesFunction · 0.45
mainFunction · 0.45
PreVisitMethod · 0.45
AppendLiteralFunction · 0.45
PostVisitMethod · 0.45
AppendCCCharFunction · 0.45
AppendCCRangeFunction · 0.45
ConvertLatin1ToUTF8Function · 0.45
GlobalReplaceMethod · 0.45
PossibleMatchRangeMethod · 0.45
RewriteMethod · 0.45
AppendToStringMethod · 0.45

Calls

no outgoing calls

Tested by 4

TESTFunction · 0.36
TESTFunction · 0.36
operator<<Function · 0.36
operator+Function · 0.36