LibJWT Dev
The C JSON Web Token Library +JWK +JWKS
Memory Handlers

These functions allow you to get or set memory allocation functions. More...

Collaboration diagram for Memory Handlers:

Typedefs

typedef void *(* jwt_malloc_t) (size_t)
 Prototype for malloc(3)
 
typedef void *(* jwt_realloc_t) (void *, size_t)
 Prototype for realloc(3)
 
typedef void(* jwt_free_t) (void *)
 Prototype for free(3)
 

Functions

int jwt_set_alloc (jwt_malloc_t pmalloc, jwt_realloc_t prealloc, jwt_free_t pfree)
 Set functions to be used for allocating and freeing memory.
 
void jwt_get_alloc (jwt_malloc_t *pmalloc, jwt_realloc_t *prealloc, jwt_free_t *pfree)
 Get functions used for allocating and freeing memory.
 

Detailed Description

These functions allow you to get or set memory allocation functions.

Typedef Documentation

◆ jwt_free_t

typedef void(* jwt_free_t) (void *)

Prototype for free(3)

Definition at line 256 of file jwt.h.

◆ jwt_malloc_t

typedef void *(* jwt_malloc_t) (size_t)

Prototype for malloc(3)

Definition at line 246 of file jwt.h.

◆ jwt_realloc_t

typedef void *(* jwt_realloc_t) (void *, size_t)

Prototype for realloc(3)

Definition at line 251 of file jwt.h.

Function Documentation

◆ jwt_get_alloc()

void jwt_get_alloc ( jwt_malloc_t * pmalloc,
jwt_realloc_t * prealloc,
jwt_free_t * pfree )

Get functions used for allocating and freeing memory.

Parameters
pmallocPointer to malloc function output variable, or NULL
preallocPointer to realloc function output variable, or NULL
pfreePointer to free function output variable, or NULL

◆ jwt_set_alloc()

int jwt_set_alloc ( jwt_malloc_t pmalloc,
jwt_realloc_t prealloc,
jwt_free_t pfree )

Set functions to be used for allocating and freeing memory.

By default, LibJWT uses malloc, realloc, and free for memory management. This function allows the user of the library to specify its own memory management functions. This is especially useful on Windows where mismatches in runtimes across DLLs can cause problems.

The caller can specify either a valid function pointer for any of the parameters or NULL to use the corresponding default allocator function.

Note that this function will also set the memory allocator for the Jansson library.

Parameters
pmallocThe function to use for allocating memory or NULL to use malloc
preallocThe function to use for reallocating memory or NULL to use realloc
pfreeThe function to use for freeing memory or NULL to use free
Returns
0 on success or errno otherwise.