Initialize value before creating slice

pull/17140/head
Vijay Pai 6 years ago
parent 35e1f9fa6a
commit 432b34bf74
  1. 8
      test/cpp/qps/client.h
  2. 1
      test/cpp/qps/server_async.cc

@ -94,9 +94,11 @@ class ClientRequestCreator<ByteBuffer> {
public:
ClientRequestCreator(ByteBuffer* req, const PayloadConfig& payload_config) {
if (payload_config.has_bytebuf_params()) {
std::unique_ptr<char[]> buf(
new char[payload_config.bytebuf_params().req_size()]);
Slice slice(buf.get(), payload_config.bytebuf_params().req_size());
size_t req_sz =
static_cast<size_t>(payload_config.bytebuf_params().req_size());
std::unique_ptr<char[]> buf(new char[req_sz]);
memset(buf.get(), 0, req_sz);
Slice slice(buf.get(), req_sz);
*req = ByteBuffer(&slice, 1);
} else {
GPR_ASSERT(false); // not appropriate for this specialization

@ -562,6 +562,7 @@ static Status ProcessGenericRPC(const PayloadConfig& payload_config,
request->Clear();
int resp_size = payload_config.bytebuf_params().resp_size();
std::unique_ptr<char[]> buf(new char[resp_size]);
memset(buf.get(), 0, static_cast<size_t>(resp_size));
Slice slice(buf.get(), resp_size);
*response = ByteBuffer(&slice, 1);
return Status::OK;

Loading…
Cancel
Save