This is an automated email from the ASF dual-hosted git repository.

cliffjansen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c0b03f  PROTON-2517: for pn_data used by emitters, save point, 
rewind, restore.  This closes #362
4c0b03f is described below

commit 4c0b03f8e4dcb632b8232f6c5b97ce20156ae3f3
Author: Cliff Jansen <[email protected]>
AuthorDate: Mon Mar 14 12:16:10 2022 -0700

    PROTON-2517: for pn_data used by emitters, save point, rewind, restore.  
This closes #362
---
 c/src/core/emitters.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/c/src/core/emitters.h b/c/src/core/emitters.h
index 1d10f34..5a5614e 100644
--- a/c/src/core/emitters.h
+++ b/c/src/core/emitters.h
@@ -534,12 +534,23 @@ static inline void emit_copy(pni_emitter_t* emitter, 
pni_compound_context* compo
   if (!data || pn_data_size(data) == 0) {
     pni_emitter_writef8(emitter, PNE_NULL);
   } else {
+    pn_handle_t point = pn_data_point(data);
+    pn_data_rewind(data);
     pni_emitter_data(emitter, data);
+    pn_data_restore(data, point);
   }
   compound->count++;
 }
 
 static inline void emit_multiple(pni_emitter_t* emitter, pni_compound_context* 
compound, pn_data_t* data) {
+  pn_handle_t point = {0};
+  if (data) {
+    point = pn_data_point(data);
+    pn_data_rewind(data);
+    // Rewind and position to first node so data type is defined.
+    pn_data_next(data);
+  }
+
   emit_accumulated_nulls(emitter, compound);
   if (!data || pn_data_size(data) == 0) {
     pni_emitter_writef8(emitter, PNE_NULL);
@@ -560,7 +571,10 @@ static inline void emit_multiple(pni_emitter_t* emitter, 
pni_compound_context* c
   } else {
     pni_emitter_data(emitter, data);
   }
+
   compound->count++;
+  if (data)
+    pn_data_restore(data, point);
 }
 
 static inline void emit_described_type_copy(pni_emitter_t* emitter, 
pni_compound_context* compound, uint64_t descriptor, pn_data_t* data) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to