ta/pkcs11/src/token_capabilities.c
/*
 * tee_malloc_mechanism_array - Allocate and fill array of supported mechanisms
 * @count: [in] [out] Pointer to number of mechanism IDs in client resource
 * Return allocated array of the supported mechanism IDs
 *
 * Allocates array with 32bit cells mechanism IDs for the supported ones only
 * if *@count covers number mechanism IDs exposed.
 */
Allocate and fill array of supported mechanisms
@count: [in] [out] Pointer to number of mechanism IDs in client resource
Return allocated array of the supported mechanism IDs

Allocates array with 32bit cells mechanism IDs for the supported ones only
if *@count covers number mechanism IDs exposed.
Allocate and fill array of supported mechanisms @count : [ in ] [ out ] Pointer to number of mechanism IDs in client resource Return allocated array of the supported mechanism IDs Allocates array with 32bit cells mechanism IDs for the supported ones only if * @count covers number mechanism IDs exposed .
uint32_t *tee_malloc_mechanism_list(size_t *out_count)
{
	size_t n = 0;
	size_t count = 0;
	uint32_t *array = NULL;
	for (n = 0; n < ARRAY_SIZE(token_mechanism); n++)
		if (token_mechanism[n].flags)
			count++;
	if (*out_count >= count)
		array = TEE_Malloc(count * sizeof(*array),
				   TEE_USER_MEM_HINT_NO_FILL_ZERO);
	*out_count = count;
	if (!array)
		return NULL;
	for (n = 0; n < ARRAY_SIZE(token_mechanism); n++) {
		if (token_mechanism[n].flags) {
			count--;
			array[count] = token_mechanism[n].id;
		}
	}
	assert(!count);
	return array;
}
uint32_t * tee_malloc_mechanism_list ( size_t * out_count ) { size_t n = 0 ; size_t count = 0 ; uint32_t * array = NULL ; for ( n = 0 ; n < ARRAY_SIZE ( token_mechanism ) ; n ++ ) if ( token_mechanism [ n ] . flags ) count ++ ; if ( * out_count >= count ) array = TEE_Malloc ( count * sizeof ( * array ) , TEE_USER_MEM_HINT_NO_FILL_ZERO ) ; * out_count = count ; if ( ! array ) return NULL ; for ( n = 0 ; n < ARRAY_SIZE ( token_mechanism ) ; n ++ ) { if ( token_mechanism [ n ] . flags ) { count -- ; array [ count ] = token_mechanism [ n ] . id ; } } assert ( ! count ) ; return array ; }
tee_malloc_mechanism_array - Allocate and fill array of supported mechanisms
 @count: [in] [out] Pointer to number of mechanism IDs in client resource
 Return allocated array of the supported mechanism IDs
tee_malloc_mechanism_array - Allocate and fill array of supported mechanisms @count : [ in ] [ out ] Pointer to number of mechanism IDs in client resource Return allocated array of the supported mechanism IDs