---
name: "tlsrpt_set_malloc_and_free"
section: "3"
platform: "linux"
package: "libtlsrpt"
version: "0.5.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/tlsrpt_set_malloc_and_free"
---

# tlsrpt\_set\_malloc\_and\_free(3)

replaces the malloc implementation used within libtlsrpt

## NAME

tlsrpt\_set\_malloc\_and\_free - replaces the malloc implementation used within libtlsrpt

## SYNOPSIS

\#include \<tlsrpt.h\>

void tlsrpt\_set\_malloc\_and\_free(void\* (\*malloc\_function)(size\_t size), void (\*free\_function)(void \*ptr))

## DESCRIPTION

The `tlsrpt_set_malloc_and_free` function replaces the malloc implementation used within libtlsrpt. The replaced malloc is used within libtlsrpt only to allocate the `struct tlsrpt_connection_t` and `struct tlsrpt_dr_t` structures. Other malloc calls from within the C standard library are not affected.

**Note**\

This function must be called before any of the allocating functions `tlsrpt_open` and `tlsrpt_init_delivery_request` is called! Otherwise one malloc implementation tries to free  a pointer allocated by a different malloc implementation.

## RETURN VALUE

The tlsrpt\_set\_malloc\_and\_free function has no return value.

## SEE ALSO

man:tlsrpt\_open\[3\], man:tlsrpt\_init\_delivery\_request\[3\]

## AUTHOR

Boris Lohner
