Tss2_TctiLdr_Finalize(3)

✨ Tss2_TctiLdr_Finalize(3) ✨

okay bestie, gather round πŸ’– this one is from the Library Functions Manual, and it's the little cleanup queen of the TCTI loader world. she doesn't do much, but what she does is essential.


🌸 NAME 🌸

Tss2_TctiLdr_Finalize β€” the function that finalizes a TCTI context that was instantiated by the Tss2_TctiLdr_Initialize function. it's the goodbye hug. the closing tab. the "ok love u bye" 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <tss2/tss2_tctildr.h>

TSS2_RC Tss2_TctiLdr_Finalize (TSS2_TCTI_CONTEXT **CONTEXT);

like yes, she's a function, and yes, she returns a TSS2_RC up there in the signature, but babe β€” read the RETURN VALUE section before you @ me 😭


πŸ’… DESCRIPTION πŸ’…

so. Tss2_TctiLdr_Finalize() destroys an instance of a TCTI context that got instantiated by the Tss2_TctLdr_Initialize() function. it also frees any resources associated with loading the required TCTI library β€” so like, not just the context itself, but the whole loading situation too. full cleanup. main character exit. ✨

the context parameter is a double pointer to a TCTI context. and here's the cute part: when it's successfully finalized, the provided reference gets set to NULL by the function. she doesn't leave dangling pointers behind, she's not messy like that πŸ’…

heads up bestie: it's a double pointer (**CONTEXT) for a reason β€” she needs to reach back and null out your pointer for you. don't fight it, just pass the address. 🫢

⭐ RETURN VALUE ⭐

This function returns no value. that's it. that's the whole section. she's too iconic to give you a return code, ngl πŸ’€


πŸ”₯ EXAMPLE πŸ”₯

Example code. (yes the vibes are immaculate, no we did not write it, we're just passing it along fr fr)

#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>

#include <tss2/tss2_tctildr.h>

TSS2_TCTI_CONTEXT *ctx = NULL;
TSS2_RC rc = Tss2_TctiLdr_Initialize (NULL, NULL, &ctx);
if (rc != TSS2_RC_SUCCESS) {
    fprintf (stderr, "Initialization of default TCTI context failed with "
             "response code: 0x%" PRIx32 "0, rc);
    exit (EXIT_FAILURE);
}

if (ctx != NULL)
    Tss2_TctiLdr_Finalize (&ctx);

exit (EXIT_SUCCESS);

see how she checks if (ctx != NULL) first before finalizing? that's the vibe check βœ… only say bye if there's actually someone to say bye to.


πŸ‘‘ AUTHOR πŸ‘‘

TPM2 Software Project <https://github.com/tpm2-software/tpm2-tss> β€” the legends themselves, no cap 🫑


πŸ¦‹ SEE ALSO πŸ¦‹

go read the Initialize one too so you know what you're finalizing, iykyk πŸ’œ


🌈 COLOPHON 🌈

This page is part of release 4.2.0 of Open Source implementation of the TCG TPM2 Software Stack (TSS2). A description of the project, information about reporting bugs, and the latest version of this page can be found at <https://github.com/tpm2-software/tpm2-tss/>. πŸ“


🧚 LICENSE 🧚

This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). For more information visit <https://creativecommons.org/licenses/by/4.0/> β€” share it, remix it, just credit the girlies πŸ’–


okay that's the whole page, bestie!! this one shipped with the TPM2 Software Stack, dated MARCH 2019 (a vintage era, honestly), from release 4.2.0 of the Open Source implementation of the TCG TPM2 Software Stack (TSS2). now go NULL out those pointers responsibly. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from