shibd commented on code in PR #254:
URL: https://github.com/apache/pulsar-client-cpp/pull/254#discussion_r1171035536
##########
include/pulsar/c/consumer.h:
##########
@@ -119,6 +121,17 @@ PULSAR_PUBLIC void
pulsar_consumer_receive_async(pulsar_consumer_t *consumer,
PULSAR_PUBLIC pulsar_result pulsar_consumer_batch_receive(pulsar_consumer_t
*consumer,
pulsar_messages_t
**msgs);
+/**
+ * Async batch receiving messages.
+ *
+ * @param callback
+ * 1. When it's callback call result is `ResultOk`, `*msg` will point to the
memory that
+ * is allocated internally. You have to call `pulsar_messages_free` to free it.
+ * 2. If callback call result is not `ResultOk`, `*msg` will is nullptr.
Review Comment:
I see.
> Isn't *msg a pointer representing pulsar_messages_t object?
This statement is wrong and should be: `msg is a pointer representing
pulsar_messages_t object.`
Let's get back to the discussion. The flow code.
```c
pulsar_messages_t *msgs = nullptr;
if (result == pulsar::ResultOk) {
msgs = new pulsar_messages_t;
// set data.
}
callback((pulsar_result)result, msgs, ctx);
```
- `msgs` is a pointer that points to a pulsar_messages_t object.
- `*msgs` is the pulsar_messages_t object that msg points to.
So, I pass a `msgs` is not `*msgs`. What I passed in was a pointer, right?
I can pass in a `nullptr`.
I need change note
```diff
- * 1. When the result in the callback is `ResultOk`, `*msg` in the callback
will point to the memory that
- * is allocated internally. You have to call `pulsar_messages_free` to free
it.
- * 2. If the result in the callback is not `ResultOk`, `*msg` in the
callback will is nullptr.
+ * 1. When the result in the callback is `ResultOk`, `msg` in the callback
will point to the memory that
+ * is allocated internally. You have to call `pulsar_messages_free` to free
it.
+ * 2. If the result in the callback is not `ResultOk`, `msg` in the
callback will is nullptr.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]