let dds_get_qos reset the input qos first
Getting a QoS from an entity is akin to reading, and all read/take operations reuse or free/reallocate memory to avoid memory leaks, and so it is a reasonable assumption that calling dds_get_qos repeatedly without intervening calls to dds_reset_qos would not leak any memory either. (This was actually an assumption in the builtin topics test.) Therefore, it is reasonable to first call dds_reset_qos in dds_get_qos. All operations in the API that yield or modify a QoS object result in a properly initialised one, therefore the input to dds_get_qos is necessarily initialised, and so this is safe. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
		
							parent
							
								
									102e657d45
								
							
						
					
					
						commit
						98f757a5ab
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -363,10 +363,13 @@ dds_return_t dds_get_qos (dds_entity_t entity, dds_qos_t *qos)
 | 
			
		|||
  if ((rc = dds_entity_lock (entity, DDS_KIND_DONTCARE, &e)) != DDS_RETCODE_OK)
 | 
			
		||||
    return DDS_ERRNO (rc);
 | 
			
		||||
 | 
			
		||||
  if (e->m_deriver.set_qos)
 | 
			
		||||
    ret = dds_copy_qos (qos, e->m_qos);
 | 
			
		||||
  else
 | 
			
		||||
  if (e->m_deriver.set_qos == 0)
 | 
			
		||||
    ret = DDS_ERRNO(DDS_RETCODE_ILLEGAL_OPERATION);
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    dds_reset_qos (qos);
 | 
			
		||||
    ret = dds_copy_qos (qos, e->m_qos);
 | 
			
		||||
  }
 | 
			
		||||
  dds_entity_unlock(e);
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue