firmware/lib/tpm2_lite/marshaling.c
/*
 * Each unmarshaling function receives a pointer to the buffer pointer and a
 * pointer to the size of data still in the buffer. The function extracts data
 * from the buffer and adjusts both buffer pointer and remaining data size.
 *
 * Should there be not enough data in the buffer to unmarshal the required
 * object, the remaining data size is set to -1 to indicate the error. The
 * remaining data size is expected to be set to zero once the last data item
 * has been extracted from the buffer.
 */
Each unmarshaling function receives a pointer to the buffer pointer and a
pointer to the size of data still in the buffer. The function extracts data
from the buffer and adjusts both buffer pointer and remaining data size.

Should there be not enough data in the buffer to unmarshal the required
object, the remaining data size is set to -1 to indicate the error. The
remaining data size is expected to be set to zero once the last data item
has been extracted from the buffer.
Each unmarshaling function receives a pointer to the buffer pointer and a pointer to the size of data still in the buffer . The function extracts data from the buffer and adjusts both buffer pointer and remaining data size . Should there be not enough data in the buffer to unmarshal the required object the remaining data size is set to - 1 to indicate the error . The remaining data size is expected to be set to zero once the last data item has been extracted from the buffer .
static uint8_t unmarshal_u8(void **buffer, int *buffer_space)
{
	uint8_t value;
	if (*buffer_space < sizeof(value)) {
		*buffer_space = -1; 
		return 0;
	}
	value = *(uint8_t *)(*buffer);
	*buffer = (void *) ((uintptr_t) (*buffer) + sizeof(value));
	*buffer_space -= sizeof(value);
	return value;
}
static uint8_t unmarshal_u8 ( void * * buffer , int * buffer_space ) { uint8_t value ; if ( * buffer_space < sizeof ( value ) ) { * buffer_space = -1 ; return 0 ; } value = * ( uint8_t * ) ( * buffer ) ; * buffer = ( void * ) ( ( uintptr_t ) ( * buffer ) + sizeof ( value ) ) ; * buffer_space -= sizeof ( value ) ; return value ; }
Each unmarshaling function receives a pointer to the buffer pointer and a
 pointer to the size of data still in the buffer.
Each unmarshaling function receives a pointer to the buffer pointer and a pointer to the size of data still in the buffer .
/* Indicate a failure. */