TPM_Malloc man page

TPM_Malloc — Allocate memory

TPM_Realloc — Reallocate memory

TPM_Free — Free memory


#include <libtpms/tpm_types.h>

#include <libtpms/tpm_memory.h>

#include <libtpms/tpm_error.h>

TPM_RESULT TPM_Malloc(unsigned char **buffer,
uint32_t size);

TPM_RESULT TPM_Realloc(unsigned char **buffer,
uint32_t size);

void TPM_Free(unsigned char *buffer);


The TPM_Malloc() function is used to allocate a buffer of the given size. The allocated buffer will be returned in the buffer parameter.

The TPM_Realloc() function is used to resize a buffer. The new size of the buffer is given in the size parameter. The reallocated buffer will contain the data from the original buffer.

Both functions have the restriction that the buffer they can allocate is limited to TPM_ALLOC_MAX (64k) bytes. This size is sufficent for all buffers needed by the TPM.

Upon successful completion, the functions return TPM_SUCCESS. In case the requested buffer exceeds the limit, TPM_SIZE will be returned. See further possible error codes below.

The TPM_Free() function frees the memory previously allocated using either TPM_Malloc() or TPM_Realloc().


The function completed sucessfully.
The size of the requested buffer exceeds the limit or the system is out of memory.
Requested buffer is of size 0.

For a complete list of TPM error codes please consult the include file libtpms/tpm_error.h

See Also

TPMLIB_MainInit(3), TPMLIB_Terminate(3) TPMLIB_Process(3), TPMLIB_RegisterCallbacks(3), TPMLIB_GetVersion(3)

Referenced By

Explore man page connections for TPM_Malloc(3).

TPM_Free(3) and TPM_Realloc(3) are aliases of TPM_Malloc(3).

libtpms 0.5.1 2011-10-12