X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fcommon%2Fsrc%2Fmbuf_api.c;h=58225c457e54fc419fa38312b3f14f4877d6dcc4;hb=refs%2Fchanges%2F23%2F5523%2F1;hp=6dbc71ae4aa0c825881a73f131f93707255a9a8c;hpb=f4a2227da63b7dd64310d24b285cffb44d159746;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/common/src/mbuf_api.c b/src/rmr/common/src/mbuf_api.c index 6dbc71a..58225c4 100644 --- a/src/rmr/common/src/mbuf_api.c +++ b/src/rmr/common/src/mbuf_api.c @@ -284,6 +284,10 @@ extern unsigned char* rmr_get_meid( rmr_mbuf_t* mbuf, unsigned char* dest ) { The return value is the number of bytes actually coppied. If 0 bytes are coppied errno should indicate the reason. If 0 is returned and errno is 0, then size passed was 0. The state in the message is left UNCHANGED. + + Regardless of action taken (actual realloc or not) the caller's reference to mbuf + is still valid follwing the call and will point to the correct spot (same tp + buffer if no realloc needed, or the new one if there was). */ extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size ) { uta_mhdr_t* hdr; @@ -312,7 +316,7 @@ extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size ) if( len != size ) { // different sized trace data, must realloc the buffer nm = rmr_realloc_msg( msg, size ); // realloc with changed trace size - old_tp_buf = msg->tp_buf; + old_tp_buf = msg->tp_buf; // hold to repoint new mbuf at small buffer old_hdr = msg->header; msg->tp_buf = nm->tp_buf; // reference the reallocated buffer @@ -321,7 +325,7 @@ extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size ) msg->xaction = nm->xaction; msg->payload = nm->payload; - nm->tp_buf = old_tp_buf; // set to free + nm->tp_buf = old_tp_buf; // set to free; point to the small buffer nm->header = old_hdr; // nano frees on hdr, so must set both rmr_free_msg( nm );