MCPcopy Create free account
hub / github.com/apache/brpc / SetArray

Method SetArray

src/brpc/redis_reply.cpp:416–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416void RedisReply::SetArray(int size) {
417 if (_type != REDIS_REPLY_NIL) {
418 Reset();
419 }
420 _type = REDIS_REPLY_ARRAY;
421 if (size < 0) {
422 LOG(ERROR) << "negative size=" << size << " when calling SetArray";
423 return;
424 } else if (size == 0) {
425 _length = 0;
426 return;
427 }
428 RedisReply* subs = (RedisReply*)_arena->allocate(sizeof(RedisReply) * size);
429 if (!subs) {
430 LOG(FATAL) << "Fail to allocate RedisReply[" << size << "]";
431 return;
432 }
433 for (int i = 0; i < size; ++i) {
434 new (&subs[i]) RedisReply(_arena);
435 }
436 _length = size;
437 _data.array.replies = subs;
438}
439
440void RedisReply::SetStringImpl(const butil::StringPiece& str, RedisReplyType type) {
441 if (_type != REDIS_REPLY_NIL) {

Callers 5

TEST_FFunction · 0.80
OnBatchedMethod · 0.80
RunMethod · 0.80
RunMethod · 0.80
FillSlotEntryMethod · 0.80

Calls 1

allocateMethod · 0.45

Tested by 5

TEST_FFunction · 0.64
OnBatchedMethod · 0.64
RunMethod · 0.64
RunMethod · 0.64
FillSlotEntryMethod · 0.64