ganeshmurthy commented on a change in pull request #1515:
URL: https://github.com/apache/qpid-dispatch/pull/1515#discussion_r806073948
##########
File path: include/qpid/dispatch/compose.h
##########
@@ -262,6 +263,92 @@ void qd_compose_insert_opaque_elements(qd_composed_field_t
*field,
*/
void qd_compose_insert_double(qd_composed_field_t *field, double value);
+/**
+ * Write a uint32 value in network order to buf.
+ *
+ * This is used throughout the code for writing the size and count components
+ * of variable-sized AMQP types.
+ *
+ * The caller must ensure buf references four contiguous octets in memory.
+ */
+static inline void qd_compose_uint32_encode(uint32_t value, uint8_t buf[])
+{
+ buf[0] = (uint8_t) ((value & 0xFF000000) >> 24);
+ buf[1] = (uint8_t) ((value & 0x00FF0000) >> 16);
+ buf[2] = (uint8_t) ((value & 0x0000FF00) >> 8);
+ buf[3] = (uint8_t) (value & 0x000000FF);
+}
+
+/**
+ * Compose the proper header for a map given entry count and data size.
+ *
+ * The caller must ensure hdr references nine contiguous octets in memory.
+ *
+ * @param size length of encoded map body (not including sizeof(count))
+ * @param count total number of elements in the map
+ * @return length of data in hdr in octets
+ */
+static inline int qd_compose_map_header(uint8_t hdr[], uint32_t size, uint32_t
count)
+{
+ if (count < 256 && size + 1 < 256) {
Review comment:
I was wondering if we could use some constant here instead of 256. That
constant can be used in other places in this file
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]