MCPcopy Create free account
hub / github.com/apache/trafficserver / get_info_from_buffer

Function get_info_from_buffer

example/plugins/c-api/protocol/TxnSM.cc:914–947  ·  view source on GitHub ↗

Read data out through the_reader and save it in a char buffer. */

Source from the content-addressed store, hash-verified

912
913/* Read data out through the_reader and save it in a char buffer. */
914char *
915get_info_from_buffer(TSIOBufferReader the_reader)
916{
917 char *info;
918 char *info_start;
919
920 int64_t read_avail, read_done;
921
922 if (!the_reader) {
923 return nullptr;
924 }
925
926 read_avail = TSIOBufferReaderAvail(the_reader);
927
928 info = static_cast<char *>(TSmalloc(sizeof(char) * read_avail));
929 if (info == nullptr) {
930 return nullptr;
931 }
932 info_start = info;
933
934 /* Read the data out of the reader */
935 while (read_avail > 0) {
936 TSIOBufferBlock blk = TSIOBufferReaderStart(the_reader);
937 char *buf = const_cast<char *>(TSIOBufferBlockReadStart(blk, the_reader, &read_done));
938 memcpy(info, buf, read_done);
939 if (read_done > 0) {
940 TSIOBufferReaderConsume(the_reader, read_done);
941 read_avail -= read_done;
942 info += read_done;
943 }
944 }
945
946 return info_start;
947}
948
949/* Check if the end token is in the char buffer. */
950int

Callers 2

process_fetch_readMethod · 0.85

Calls 6

TSIOBufferReaderAvailFunction · 0.85
TSmallocFunction · 0.85
TSIOBufferReaderStartFunction · 0.50
TSIOBufferBlockReadStartFunction · 0.50
memcpyFunction · 0.50
TSIOBufferReaderConsumeFunction · 0.50

Tested by

no test coverage detected