.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "TPM_Malloc 3" .TH TPM_Malloc 3 2024-03-09 libtpms "" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME TPM_Malloc \- Allocate memory .PP TPM_Realloc \- Reallocate memory .PP TPM_Free \- Free memory .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fB#include .PP \&\fB#include .PP \&\fB#include .PP \&\fBTPM_RESULT TPM_Malloc(unsigned char\fR **\fIbuffer\fR\fB, uint32_t\fR \fIsize\fR\fB);\fR .PP \&\fBTPM_RESULT TPM_Realloc(unsigned char\fR **\fIbuffer\fR\fB, uint32_t\fR \fIsize\fR\fB);\fR .PP \&\fBvoid TPM_Free(unsigned char\fR *\fIbuffer\fR\fB);\fR .SH DESCRIPTION .IX Header "DESCRIPTION" The \fBTPM_Malloc()\fR function is used to allocate a buffer of the given size. The allocated buffer will be returned in the \fIbuffer\fR parameter. .PP The \fBTPM_Realloc()\fR function is used to resize a buffer. The new size of the buffer is given in the \fIsize\fR parameter. The reallocated buffer will contain the data from the original buffer. .PP Both functions have the restriction that the buffer they can allocate is limited to \fBTPM_ALLOC_MAX\fR (64k) bytes. This size is sufficient for all buffers needed by the TPM. .PP Upon successful completion, the functions return \fBTPM_SUCCESS\fR. In case the requested buffer exceeds the limit, \fBTPM_SIZE\fR will be returned. See further possible error codes below. .PP The \fBTPM_Free()\fR function frees the memory previously allocated using either \fBTPM_Malloc()\fR or \fBTPM_Realloc()\fR. .SH ERRORS .IX Header "ERRORS" .IP \fBTPM_SUCCESS\fR 4 .IX Item "TPM_SUCCESS" The function completed successfully. .IP \fBTPM_SIZE\fR 4 .IX Item "TPM_SIZE" The size of the requested buffer exceeds the limit or the system is out of memory. .IP \fBTPM_FAIL\fR 4 .IX Item "TPM_FAIL" Requested buffer is of size 0. .PP For a complete list of TPM error codes please consult the include file \&\fBlibtpms/tpm_error.h\fR .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBTPMLIB_MainInit\fR(3), \fBTPMLIB_Terminate\fR(3) \&\fBTPMLIB_Process\fR(3), \fBTPMLIB_RegisterCallbacks\fR(3), \fBTPMLIB_GetVersion\fR(3)