From 444dcaf3525ccaa642d4eba0c724ffe99d11da59 Mon Sep 17 00:00:00 2001 From: Changhua Date: Sun, 30 Apr 2023 18:11:02 +0800 Subject: [PATCH] Fix encode_dbnames --- rpc/pb_util.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rpc/pb_util.cpp b/rpc/pb_util.cpp index c8aa23b..fa13d4b 100644 --- a/rpc/pb_util.cpp +++ b/rpc/pb_util.cpp @@ -109,19 +109,14 @@ bool encode_contacts(pb_ostream_t *stream, const pb_field_t *field, void *const bool encode_dbnames(pb_ostream_t *stream, const pb_field_t *field, void *const *arg) { - vector *v = (vector *)*arg; - DbNames message = DbNames_init_default; - + DbNames_t *v = (DbNames_t *)*arg; for (auto it = v->begin(); it != v->end(); it++) { - message.names.funcs.encode = &encode_string; - message.names.arg = (void *)(*it).c_str(); - if (!pb_encode_tag_for_field(stream, field)) { LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(stream)); return false; } - if (!pb_encode_submessage(stream, DbNames_fields, &message)) { + if (!pb_encode_string(stream, (uint8_t *)(*it).c_str(), (*it).size())) { LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(stream)); return false; }