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

Method x_getbytes

src/remote/inet.cpp:2571–2635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2569
2570
2571bool_t InetXdr::x_getbytes(SCHAR* buff, unsigned bytecount)
2572{
2573/**************************************
2574 *
2575 * i n e t _ g e t b y t e s
2576 *
2577 **************************************
2578 *
2579 * Functional description
2580 * Get a bunch of bytes from a memory stream if it fits.
2581 *
2582 **************************************/
2583 if (x_public->port_flags & PORT_server)
2584 return REMOTE_getbytes(this, buff, bytecount);
2585
2586 // Use memcpy to optimize bulk transfers.
2587
2588 while (bytecount > sizeof(ISC_QUAD))
2589 {
2590 if (x_handy >= bytecount)
2591 {
2592 memcpy(buff, x_private, bytecount);
2593 x_private += bytecount;
2594 x_handy -= bytecount;
2595 return TRUE;
2596 }
2597
2598 if (x_handy > 0)
2599 {
2600 memcpy(buff, x_private, x_handy);
2601 x_private += x_handy;
2602 buff += x_handy;
2603 bytecount -= x_handy;
2604 x_handy = 0;
2605 }
2606
2607 if (!inet_read(this))
2608 return FALSE;
2609 }
2610
2611 // Scalar values and bulk transfer remainder fall thru
2612 // to be moved byte-by-byte to avoid memcpy setup costs.
2613
2614 if (!bytecount)
2615 return TRUE;
2616
2617 if (x_handy >= bytecount)
2618 {
2619 x_handy -= bytecount;
2620 while (bytecount--)
2621 *buff++ = *x_private++;
2622
2623 return TRUE;
2624 }
2625
2626 while (bytecount--)
2627 {
2628 if (x_handy == 0 && !inet_read(this))

Callers 3

xdr_bytesFunction · 0.45
xdr_cstring_with_limitFunction · 0.45
xdr_blobBufferFunction · 0.45

Calls 2

REMOTE_getbytesFunction · 0.85
inet_readFunction · 0.85

Tested by

no test coverage detected