X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fcommon%2Fsrc%2Fring_static.c;h=99fdea8b828f327c21a7f8b8f047c1f600fde1c0;hb=11838bcf76f3614384459cb56e2ce80dea788cef;hp=7170a9d0795caadaa191673891f8f67a699f5ffa;hpb=8c6756d9d6f94beca0bc382f97383ca5e79d16c7;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/common/src/ring_static.c b/src/rmr/common/src/ring_static.c index 7170a9d..99fdea8 100644 --- a/src/rmr/common/src/ring_static.c +++ b/src/rmr/common/src/ring_static.c @@ -71,7 +71,10 @@ static void* uta_mk_ring( int size ) { ring_t* r; uint16_t max; - if( size <= 0 || (r = (ring_t *) malloc( sizeof( *r ) )) == NULL ) { + if( size <= 0 ) { + return NULL; + } + if( (r = (ring_t *) malloc( sizeof( *r ) )) == NULL ) { return NULL; } @@ -114,15 +117,13 @@ static int uta_ring_config( void* vr, int options ) { return 0; } - if( options & RING_WLOCK ) { - if( r->wgate == NULL ) { // don't realloc - r->wgate = (pthread_mutex_t *) malloc( sizeof( *r->wgate ) ); - if( r->wgate == NULL ) { - return 0; - } - - pthread_mutex_init( r->wgate, NULL ); + if( options & RING_WLOCK && r->wgate == NULL ) { // don't realloc if we have one + r->wgate = (pthread_mutex_t *) malloc( sizeof( *r->wgate ) ); + if( r->wgate == NULL ) { + return 0; } + + pthread_mutex_init( r->wgate, NULL ); } if( options & (RING_RLOCK | RING_FRLOCK) ) { // read locking