+
+ if payload is not None, attempts to set the payload
+ if gen_transaction_id is True, it generates and sets a transaction id
+ if mtype is not None, sets the sbuf's message type
+ if meid is not None, sets the sbuf's meid
+
+ """
+ sbuf = _rmr_alloc_msg(vctx, size)
+ # make sure it's good
+ try:
+ sbuf.contents
+ if payload:
+ set_payload_and_length(payload, sbuf)
+
+ if gen_transaction_id:
+ generate_and_set_transaction_id(sbuf)
+
+ if mtype:
+ sbuf.contents.mtype = mtype
+
+ if meid:
+ rmr_set_meid(sbuf, meid)
+
+ return sbuf
+
+ except ValueError:
+ raise BadBufferAllocation
+
+
+_rmr_free_msg = rmr_c_lib.rmr_free_msg
+_rmr_free_msg.argtypes = [c_void_p]
+_rmr_free_msg.restype = None
+
+
+def rmr_free_msg(mbuf):
+ """
+ Refer to the rmr C documentation for rmr_free_msg
+ extern void rmr_free_msg( rmr_mbuf_t* mbuf )