+ sbuf = _rmr_alloc_msg(vctx, size)
+ try:
+ # make sure the alloc worked
+ sbuf.contents
+
+ # set specified fields
+ if payload:
+ set_payload_and_length(payload, sbuf)
+
+ if fixed_transaction_id:
+ set_transaction_id(sbuf, fixed_transaction_id)
+ elif gen_transaction_id:
+ generate_and_set_transaction_id(sbuf)
+
+ if mtype:
+ sbuf.contents.mtype = mtype
+
+ if meid:
+ rmr_set_meid(sbuf, meid)
+
+ if sub_id:
+ sbuf.contents.sub_id = sub_id
+
+ return sbuf
+
+ except ValueError:
+ raise BadBufferAllocation
+
+
+_rmr_realloc_payload = rmr_c_lib.rmr_realloc_payload
+_rmr_realloc_payload.argtypes = [POINTER(rmr_mbuf_t), c_int, c_int, c_int] # new_len, copy, clone
+_rmr_realloc_payload.restype = POINTER(rmr_mbuf_t)
+
+
+def rmr_realloc_payload(ptr_mbuf, new_len, copy=False, clone=False):
+ """
+ Refer to the rmr C documentation for rmr_realloc_payload().
+ extern rmr_mbuf_t* rmr_realloc_payload(rmr_mbuf_t*, int, int, int)
+ """
+ return _rmr_realloc_payload(ptr_mbuf, new_len, copy, clone)
+
+
+_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 )
+ """
+ if mbuf is not None:
+ _rmr_free_msg(mbuf)