DAPL_HCA *hca_ptr;
hca_ptr = dapl_os_alloc (sizeof (DAPL_HCA));
- if ( NULL != hca_ptr )
+ if ( NULL == hca_ptr )
{
- dapl_os_memzero (hca_ptr, sizeof (DAPL_HCA));
+ goto bail;
+ }
- if ( DAT_SUCCESS == dapls_hash_create (
+ dapl_os_memzero (hca_ptr, sizeof (DAPL_HCA));
+
+ if ( DAT_SUCCESS != dapls_hash_create (
DAPL_HASH_TABLE_DEFAULT_CAPACITY, &hca_ptr->lmr_hash_table) )
- {
- dapl_os_lock_init(&hca_ptr->lock);
- dapl_llist_init_head(&hca_ptr->ia_list_head);
+ {
+ goto bail;
+ }
+
+ dapl_os_lock_init(&hca_ptr->lock);
+ dapl_llist_init_head(&hca_ptr->ia_list_head);
- hca_ptr->name = dapl_os_strdup(name);
- hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
- hca_ptr->port_num = dapl_os_strtol(port, NULL, 0);
- if (hca_ptr->name == NULL)
- {
- dapl_os_free (hca_ptr, sizeof (DAPL_HCA));
- hca_ptr = NULL;
- }
- }
- else
- {
- dapl_os_free (hca_ptr, sizeof (DAPL_HCA));
- hca_ptr = NULL;
- }
+ hca_ptr->name = dapl_os_strdup(name);
+ if ( NULL == hca_ptr->name )
+ {
+ goto bail;
}
+
+ hca_ptr->ib_hca_handle = IB_INVALID_HANDLE;
+ hca_ptr->port_num = dapl_os_strtol(port, NULL, 0);
return (hca_ptr);
+
+bail:
+
+ if ( NULL != hca_ptr )
+ {
+ if ( NULL != hca_ptr->lmr_hash_table )
+ {
+ dapls_hash_free (hca_ptr->lmr_hash_table);
+ }
+
+ dapl_os_free (hca_ptr, sizeof (DAPL_HCA));
+ }
+
+ return NULL;
}
/*