rem: trans->outbound_response = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) ); if (!trans->outbound_response) { LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: no more shmem\n"); trans->outbound_response = NULL;
add: } else { reset_timer( hash_table, &(rb->retr_timer)); reset_timer( hash_table, &(rb->fr_timer)); }   buf = build_res_buf_from_sip_res ( trans->inbound_response[branch], &len); if (!buf) { LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: " "no shmem for outbound reply buffer\n"); goto error; } if ( !(b = (char*)sh_malloc( len ))) { LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: " "no memory to allocate retr_buffer\n"); goto error1; } if (  rb->retr_buffer ) sh_free(  rb->retr_buffer ) ; rb->retr_buffer = b; rb->bufflen = len ; memcpy( rb->retr_buffer , buf , len ); free( buf ) ;   trans->status = trans->inbound_response[branch]->REPLY_STATUS; if ( trans->inbound_response[branch]->REPLY_STATUS>=200 && trans->relaied_reply_branch==-1 ) trans->relaied_reply_branch = branch;   t_update_timers_after_sending_reply( rb );    SEND_BUFFER( rb ); return 1;  error1: free( buf ); error:
context: int push_reply_from_uac_to_uas( struct cell* trans , unsigned int branch ){   char *buf;   unsigned int len;   DBG("DEBUG: push_reply_from_uac_to_uas: start\n");   /* if there is a reply, release the buffer (everything else stays same) */   if ( trans->outbound_response )   {      sh_free( trans->outbound_response->retr_buffer );      remove_from_timer( hash_table , (&(trans->outbound_response->tl[RETRASMISSIONS_LIST])) , RETRASMISSIONS_LIST );      remove_from_timer( hash_table , (&(trans->outbound_response->tl[FR_TIMER_LIST])) , FR_TIMER_LIST );   }   else   {      struct hostent  *nhost;     char foo;      trans->outbound_response = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );      if (!trans->outbound_response) {	LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: no more shmem\n");	trans->outbound_response = NULL;	return -1;      }      /*init retrans buffer*/      memset( trans->outbound_response , 0 , sizeof (struct retrans_buff) );      trans->outbound_response->tl[RETRASMISSIONS_LIST].payload = trans->outbound_response;      trans->outbound_response->tl[FR_TIMER_LIST].payload = trans->outbound_response;      trans->outbound_response->to.sin_family = AF_INET;      trans->outbound_response->my_T = trans;      if (update_sock_struct_from_via(  &(trans->outbound_response->to),  trans->inbound_response[branch]->via2 )==-1) {	LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: cannot lookup reply dst: %s\n",		trans->inbound_response[branch]->via2->host.s );	sh_free(  T->outbound_response );	T->outbound_response = NULL;	return -1;      }   }   /*  generate the retrans buffer */   buf = build_res_buf_from_sip_res ( trans->inbound_response[branch], &len);   if (!buf) {	LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: no shmem for outbound reply buffer\n");        return -1;   }   trans->outbound_response->bufflen = len ;   trans->outbound_response->retr_buffer   = (char*)sh_malloc( len );   if (! trans->outbound_response->retr_buffer ) {	LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: no memory to allocate retr_buffer\n");	free( buf );	return -1;   }   memcpy( trans->outbound_response->retr_buffer , buf , len );   free( buf ) ;   /* update the status*/   trans->status = trans->inbound_response[branch]->first_line.u.reply.statuscode;   if ( trans->inbound_response[branch]->first_line.u.reply.statuscode>=200 &&         trans->relaied_reply_branch==-1 )       trans->relaied_reply_branch = branch;    /* start/stops the proper timers*/   t_update_timers_after_sending_reply( T->outbound_response );   /*send the reply*/   t_retransmit_reply( trans->inbound_response[branch], 0 , 0 );   return 1;}