libubx/ubx.c
ubx_block_t *ubx_block_create(ubx_node_info_t *ni, const char *type, const char *name)
{
	ubx_block_t *prot, *newb;

	newb = NULL;

	if (name == NULL) {
		logf_err(ni, "block_create: name is NULL");
		goto out;
	}

	/* find prototype */
	HASH_FIND_STR(ni->blocks, type, prot);

	if (prot == NULL) {
		logf_err(ni, "no such block %s", type);
		goto out;
	}

	/* check if name is already used */
	HASH_FIND_STR(ni->blocks, name, newb);

	if (newb != NULL) {
		logf_err(ni, "existing block named %s", name);
		newb = NULL;
		goto out;
	}

	newb = ubx_block_clone(prot, name);
	if (newb == NULL) {
		logf_crit(ni, "failed to create block %s of type %s: out of mem",
			  type, name);
		goto out;
	}

	/* register block */
	if (ubx_block_register(ni, newb) != 0) {
		logf_crit(ni, "failed to register block %s", name);
		ubx_block_free(newb);
		goto out;
	}
 out:
	return newb;
}
/**
 * @brief instantiate new block of type type with name
 *
 * @param ni
 * @param block_type
 * @param name
 *
 * @return the newly created block or NULL
 */
@brief instantiate new block of type type with name
@param ni
@param block_type
@param name

@return the newly created block or NULL
@brief instantiate new block of type type with name @param ni @param block_type @param name @return the newly created block or NULL
ubx_block_t *ubx_block_create(ubx_node_info_t *ni, const char *type, const char *name)
{
	ubx_block_t *prot, *newb;
	newb = NULL;
	if (name == NULL) {
		logf_err(ni, "block_create: name is NULL");
		goto out;
	}
	HASH_FIND_STR(ni->blocks, type, prot);
	if (prot == NULL) {
		logf_err(ni, "no such block %s", type);
		goto out;
	}
	HASH_FIND_STR(ni->blocks, name, newb);
	if (newb != NULL) {
		logf_err(ni, "existing block named %s", name);
		newb = NULL;
		goto out;
	}
	newb = ubx_block_clone(prot, name);
	if (newb == NULL) {
		logf_crit(ni, "failed to create block %s of type %s: out of mem",
			  type, name);
		goto out;
	}
	if (ubx_block_register(ni, newb) != 0) {
		logf_crit(ni, "failed to register block %s", name);
		ubx_block_free(newb);
		goto out;
	}
 out:
	return newb;
}
ubx_block_t * ubx_block_create ( ubx_node_info_t * ni , const char * type , const char * name ) { ubx_block_t * prot , * newb ; newb = NULL ; if ( name == NULL ) { logf_err ( ni , " " ) ; goto out ; } HASH_FIND_STR ( ni -> blocks , type , prot ) ; if ( prot == NULL ) { logf_err ( ni , " " , type ) ; goto out ; } HASH_FIND_STR ( ni -> blocks , name , newb ) ; if ( newb != NULL ) { logf_err ( ni , " " , name ) ; newb = NULL ; goto out ; } newb = ubx_block_clone ( prot , name ) ; if ( newb == NULL ) { logf_crit ( ni , " " , type , name ) ; goto out ; } if ( ubx_block_register ( ni , newb ) != 0 ) { logf_crit ( ni , " " , name ) ; ubx_block_free ( newb ) ; goto out ; } out : return newb ; }
@brief instantiate new block of type type with name
 @param ni
 @param block_type
 @param name
@brief instantiate new block of type type with name @param ni @param block_type @param name
/* find prototype */ /* check if name is already used */ /* register block */