1TPM_Malloc(3) TPM_Malloc(3)
2
3
4
6 TPM_Malloc - Allocate memory
7
8 TPM_Realloc - Reallocate memory
9
10 TPM_Free - Free memory
11
13 #include <libtpms/tpm_types.h>
14
15 #include <libtpms/tpm_memory.h>
16
17 #include <libtpms/tpm_error.h>
18
19 TPM_RESULT TPM_Malloc(unsigned char **buffer,
20 uint32_t size);
21
22 TPM_RESULT TPM_Realloc(unsigned char **buffer,
23 uint32_t size);
24
25 void TPM_Free(unsigned char *buffer);
26
28 The TPM_Malloc() function is used to allocate a buffer of the given
29 size. The allocated buffer will be returned in the buffer parameter.
30
31 The TPM_Realloc() function is used to resize a buffer. The new size of
32 the buffer is given in the size parameter. The reallocated buffer will
33 contain the data from the original buffer.
34
35 Both functions have the restriction that the buffer they can allocate
36 is limited to TPM_ALLOC_MAX (64k) bytes. This size is sufficient for
37 all buffers needed by the TPM.
38
39 Upon successful completion, the functions return TPM_SUCCESS. In case
40 the requested buffer exceeds the limit, TPM_SIZE will be returned. See
41 further possible error codes below.
42
43 The TPM_Free() function frees the memory previously allocated using
44 either TPM_Malloc() or TPM_Realloc().
45
47 TPM_SUCCESS
48 The function completed successfully.
49
50 TPM_SIZE
51 The size of the requested buffer exceeds the limit or the system is
52 out of memory.
53
54 TPM_FAIL
55 Requested buffer is of size 0.
56
57 For a complete list of TPM error codes please consult the include file
58 libtpms/tpm_error.h
59
61 TPMLIB_MainInit(3), TPMLIB_Terminate(3) TPMLIB_Process(3),
62 TPMLIB_RegisterCallbacks(3), TPMLIB_GetVersion(3)
63
64
65
66libtpms 2021-11-26 TPM_Malloc(3)