MCPcopy Create free account
hub / github.com/git/git / do_packet_write

Function do_packet_write

pkt-line.c:202–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202static int do_packet_write(const int fd_out, const char *buf, size_t size,
203 struct strbuf *err)
204{
205 char header[4];
206 size_t packet_size;
207
208 if (size > LARGE_PACKET_DATA_MAX) {
209 strbuf_addstr(err, _("packet write failed - data exceeds max packet size"));
210 return -1;
211 }
212
213 packet_trace(buf, size, 1);
214 packet_size = size + 4;
215
216 set_packet_header(header, packet_size);
217
218 /*
219 * Write the header and the buffer in 2 parts so that we do
220 * not need to allocate a buffer or rely on a static buffer.
221 * This also avoids putting a large buffer on the stack which
222 * might have multi-threading issues.
223 */
224
225 if (write_in_full(fd_out, header, 4) < 0 ||
226 write_in_full(fd_out, buf, size) < 0) {
227 strbuf_addf(err, _("packet write failed: %s"), strerror(errno));
228 return -1;
229 }
230 return 0;
231}
232
233static int packet_write_gently(const int fd_out, const char *buf, size_t size)
234{

Callers 2

packet_write_gentlyFunction · 0.85
packet_writeFunction · 0.85

Calls 5

strbuf_addstrFunction · 0.85
packet_traceFunction · 0.85
set_packet_headerFunction · 0.85
write_in_fullFunction · 0.85
strbuf_addfFunction · 0.85

Tested by

no test coverage detected