You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ma...@apache.org on 2019/08/06 04:35:58 UTC
[pulsar-client-node] 43/45: add skip flag for cMessageId free
This is an automated email from the ASF dual-hosted git repository.
massakam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit 5482997e01401f38912df36ea5e5594b3919dd1c
Author: hrsakai <hs...@yahoo-corp.jp>
AuthorDate: Mon Aug 5 17:17:10 2019 +0900
add skip flag for cMessageId free
---
src/MessageId.cc | 8 +++++++-
src/MessageId.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/MessageId.cc b/src/MessageId.cc
index 62cd1c8..4ba95e2 100644
--- a/src/MessageId.cc
+++ b/src/MessageId.cc
@@ -70,6 +70,7 @@ Napi::Value MessageId::Earliest(const Napi::CallbackInfo &info) {
Napi::Object obj = NewInstance(info[0]);
MessageId *msgId = Unwrap(obj);
msgId->cMessageId = (pulsar_message_id_t *)pulsar_message_id_earliest();
+ msgId->skipcMessageIdFree = true;
return obj;
}
@@ -77,6 +78,7 @@ Napi::Value MessageId::Latest(const Napi::CallbackInfo &info) {
Napi::Object obj = NewInstance(info[0]);
MessageId *msgId = Unwrap(obj);
msgId->cMessageId = (pulsar_message_id_t *)pulsar_message_id_latest();
+ msgId->skipcMessageIdFree = true;
return obj;
}
@@ -113,4 +115,8 @@ Napi::Value MessageId::ToString(const Napi::CallbackInfo &info) {
return Napi::String::New(info.Env(), pulsar_message_id_str(this->cMessageId));
}
-MessageId::~MessageId() { pulsar_message_id_free(this->cMessageId); }
+MessageId::~MessageId() {
+ if (!this->skipcMessageIdFree) {
+ pulsar_message_id_free(this->cMessageId);
+ }
+}
diff --git a/src/MessageId.h b/src/MessageId.h
index f65b1b4..6492601 100644
--- a/src/MessageId.h
+++ b/src/MessageId.h
@@ -41,6 +41,7 @@ class MessageId : public Napi::ObjectWrap<MessageId> {
private:
static Napi::FunctionReference constructor;
pulsar_message_id_t *cMessageId;
+ bool skipcMessageIdFree = false;
Napi::Value ToString(const Napi::CallbackInfo &info);
};