src/dpdk/drivers/net/mlx4/mlx4_utils.c
static inline size_t
mlx4_mallocv_inline(const char *type, const struct mlx4_malloc_vec *vec,
		    unsigned int cnt, int zero, int socket)
{
	unsigned int i;
	size_t size;
	size_t least;
	uint8_t *data = NULL;
	int fill = !vec[0].addr;

fill:
	size = 0;
	least = 0;
	for (i = 0; i < cnt; ++i) {
		size_t align = (uintptr_t)vec[i].align;

		if (!align) {
			align = sizeof(double);
		} else if (!rte_is_power_of_2(align)) {
			rte_errno = EINVAL;
			goto error;
		}
		if (least < align)
			least = align;
		align = RTE_ALIGN_CEIL(size, align);
		size = align + vec[i].size;
		if (fill && vec[i].addr)
			*vec[i].addr = data + align;
	}
	if (fill)
		return size;
	if (!zero)
		data = rte_malloc_socket(type, size, least, socket);
	else
		data = rte_zmalloc_socket(type, size, least, socket);
	if (data) {
		fill = 1;
		goto fill;
	}
	rte_errno = ENOMEM;
error:
	for (i = 0; i != cnt; ++i)
		if (vec[i].addr)
			*vec[i].addr = NULL;
	return 0;
}
/**
 * Internal helper to allocate memory once for several disparate objects.
 *
 * The most restrictive alignment constraint for standard objects is assumed
 * to be sizeof(double) and is used as a default value.
 *
 * C11 code would include stdalign.h and use alignof(max_align_t) however
 * we'll stick with C99 for the time being.
 */
Internal helper to allocate memory once for several disparate objects.
The most restrictive alignment constraint for standard objects is assumed
to be sizeof(double) and is used as a default value.

C11 code would include stdalign.h and use alignof(max_align_t) however
we'll stick with C99 for the time being.
Internal helper to allocate memory once for several disparate objects . The most restrictive alignment constraint for standard objects is assumed to be sizeof ( double ) and is used as a default value . C11 code would include stdalign . h and use alignof ( max_align_t ) however we ' ll stick with C99 for the time being .
static inline size_t
mlx4_mallocv_inline(const char *type, const struct mlx4_malloc_vec *vec,
		    unsigned int cnt, int zero, int socket)
{
	unsigned int i;
	size_t size;
	size_t least;
	uint8_t *data = NULL;
	int fill = !vec[0].addr;
fill:
	size = 0;
	least = 0;
	for (i = 0; i < cnt; ++i) {
		size_t align = (uintptr_t)vec[i].align;
		if (!align) {
			align = sizeof(double);
		} else if (!rte_is_power_of_2(align)) {
			rte_errno = EINVAL;
			goto error;
		}
		if (least < align)
			least = align;
		align = RTE_ALIGN_CEIL(size, align);
		size = align + vec[i].size;
		if (fill && vec[i].addr)
			*vec[i].addr = data + align;
	}
	if (fill)
		return size;
	if (!zero)
		data = rte_malloc_socket(type, size, least, socket);
	else
		data = rte_zmalloc_socket(type, size, least, socket);
	if (data) {
		fill = 1;
		goto fill;
	}
	rte_errno = ENOMEM;
error:
	for (i = 0; i != cnt; ++i)
		if (vec[i].addr)
			*vec[i].addr = NULL;
	return 0;
}
static inline size_t mlx4_mallocv_inline ( const char * type , const struct mlx4_malloc_vec * vec , unsigned int cnt , int zero , int socket ) { unsigned int i ; size_t size ; size_t least ; uint8_t * data = NULL ; int fill = ! vec [ 0 ] . addr ; fill : size = 0 ; least = 0 ; for ( i = 0 ; i < cnt ; ++ i ) { size_t align = ( uintptr_t ) vec [ i ] . align ; if ( ! align ) { align = sizeof ( double ) ; } else if ( ! rte_is_power_of_2 ( align ) ) { rte_errno = EINVAL ; goto error ; } if ( least < align ) least = align ; align = RTE_ALIGN_CEIL ( size , align ) ; size = align + vec [ i ] . size ; if ( fill && vec [ i ] . addr ) * vec [ i ] . addr = data + align ; } if ( fill ) return size ; if ( ! zero ) data = rte_malloc_socket ( type , size , least , socket ) ; else data = rte_zmalloc_socket ( type , size , least , socket ) ; if ( data ) { fill = 1 ; goto fill ; } rte_errno = ENOMEM ; error : for ( i = 0 ; i != cnt ; ++ i ) if ( vec [ i ] . addr ) * vec [ i ] . addr = NULL ; return 0 ; }
Internal helper to allocate memory once for several disparate objects.
Internal helper to allocate memory once for several disparate objects .