The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions
talloc.h File Reference

Functions which we wish were included in the standard talloc distribution. More...

#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <talloc.h>
#include <freeradius-devel/autoconf.h>
#include <freeradius-devel/build.h>
#include <freeradius-devel/missing.h>
#include <freeradius-devel/util/sbuff.h>
+ Include dependency graph for talloc.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_talloc_destructor_disarm_s
 Structure to record a destructor to disarm if a child talloc chunk is freed. More...
 
struct  fr_talloc_destructor_s
 Structure to record a destructor operation on a specific talloc chunk. More...
 

Macros

#define talloc_autofree_context   talloc_autofree_context_global
 The original function is deprecated, so replace it with our version. More...
 
#define talloc_foreach(_array, _iter)
 Iterate over a talloced array of elements. More...
 
#define talloc_get_type_abort_const   talloc_get_type_abort
 
#define talloc_list_free(_head)   _talloc_list_free((void **)_head, offsetof(__typeof__(**(_head)), next))
 Free a list of talloced structures containing a next field. More...
 
#define talloc_list_get_type_abort(_head, _type)   (_type *)_talloc_list_get_type_abort(_head, offsetof(__typeof__(*(_head)), next), #_type, __location__)
 Verify a list of talloced structures are the correct type and are still valid. More...
 
#define talloc_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size)    talloc(_ctx, _type)
 
#define talloc_zero_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size)    talloc_zero(_ctx, _type)
 

Typedefs

typedef struct fr_talloc_destructor_disarm_s fr_talloc_destructor_disarm_t
 
typedef struct fr_talloc_destructor_s fr_talloc_destructor_t
 
typedef int(* fr_talloc_free_func_t) (void *fire_ctx, void *uctx)
 
typedef struct talloc_child_ctx_s TALLOC_CHILD_CTX
 

Functions

static void _talloc_list_free (void **head, size_t offset)
 
static void * _talloc_list_get_type_abort (void *head, size_t offset, char const *type, char const *location)
 
TALLOC_CTX * talloc_aligned_array (TALLOC_CTX *ctx, void **start, size_t alignment, size_t size)
 Return a page aligned talloc memory array. More...
 
fr_slen_t talloc_array_concat (fr_sbuff_t *out, char const *const *array, char const *sep)
 Concat an array of strings (not NULL terminated), with a string separator. More...
 
void ** talloc_array_null_strip (void **array)
 Remove a NULL termination pointer from an array of pointers. More...
 
void ** talloc_array_null_terminate (void **array)
 Add a NULL pointer to an array of pointers. More...
 
TALLOC_CTX * talloc_autofree_context_global (void)
 
TALLOC_CTX * talloc_autofree_context_thread_local (void)
 Get a thread-safe autofreed ctx that will be freed when the thread or process exits. More...
 
char * talloc_bstr_append (TALLOC_CTX *ctx, char *to, char const *from, size_t from_len)
 Append a bstr to a bstr. More...
 
char * talloc_bstr_realloc (TALLOC_CTX *ctx, char *in, size_t inlen)
 Trim a bstr (char) buffer. More...
 
char * talloc_bstrdup (TALLOC_CTX *ctx, char const *in)
 Binary safe strdup function. More...
 
char * talloc_bstrndup (TALLOC_CTX *ctx, char const *in, size_t inlen)
 Binary safe strndup function. More...
 
char * talloc_buffer_append_buffer (TALLOC_CTX *ctx, char *to, char const *from)
 Concatenate to + from. More...
 
char * talloc_buffer_append_variadic_buffer (TALLOC_CTX *ctx, char *to, int argc,...)
 Concatenate to + ... More...
 
TALLOC_CHILD_CTXtalloc_child_ctx_alloc (TALLOC_CHILD_CTX *parent)
 Allocate a TALLOC_CHILD_CTX from a parent. More...
 
TALLOC_CHILD_CTXtalloc_child_ctx_init (TALLOC_CTX *ctx)
 Allocate and initialize a TALLOC_CHILD_CTX. More...
 
static int talloc_const_free (void const *ptr)
 Free const'd memory. More...
 
int talloc_decrease_ref_count (void const *ptr)
 Decrease the reference count on a ptr. More...
 
fr_talloc_destructor_ttalloc_destructor_add (TALLOC_CTX *fire_ctx, TALLOC_CTX *disarm_ctx, fr_talloc_free_func_t func, void const *uctx)
 Add an additional destructor to a talloc chunk. More...
 
void talloc_destructor_disarm (fr_talloc_destructor_t *d)
 Disarm a destructor and free all memory allocated in the trigger ctxs. More...
 
void talloc_free_data (void *data)
 A wrapper that can be passed to tree or hash alloc functions that take a fr_free_t. More...
 
static TALLOC_CTX * talloc_init_const (char const *name)
 Allocate a top level chunk with a constant name. More...
 
int talloc_link_ctx (TALLOC_CTX *parent, TALLOC_CTX *child)
 Link two different parent and child contexts, so the child is freed before the parent. More...
 
int talloc_memcmp_array (uint8_t const *a, uint8_t const *b)
 Compares two talloced uint8_t arrays with memcmp. More...
 
int talloc_memcmp_bstr (char const *a, char const *b)
 Compares two talloced char arrays with memcmp. More...
 
void * talloc_null_ctx (void)
 Retrieve the current talloc NULL ctx. More...
 
TALLOC_CTX * talloc_page_aligned_pool (TALLOC_CTX *ctx, void **start, void **end, size_t size)
 Return a page aligned talloc memory pool. More...
 
static size_t talloc_strlen (char const *s)
 Returns the length of a talloc array containing a string. More...
 
char * talloc_typed_asprintf (TALLOC_CTX *ctx, char const *fmt,...))
 Call talloc vasprintf, setting the type on the new chunk correctly. More...
 
uint8_ttalloc_typed_memdup (TALLOC_CTX *ctx, uint8_t const *in, size_t inlen)
 Call talloc_memdup, setting the type on the new chunk correctly. More...
 
char * talloc_typed_strdup (TALLOC_CTX *ctx, char const *p)
 Call talloc_strdup, setting the type on the new chunk correctly. More...
 
char * talloc_typed_strdup_buffer (TALLOC_CTX *ctx, char const *p)
 Call talloc_strndup, setting the type on the new chunk correctly. More...
 
char * talloc_typed_vasprintf (TALLOC_CTX *ctx, char const *fmt, va_list ap))
 Call talloc vasprintf, setting the type on the new chunk correctly. More...
 

Detailed Description

Functions which we wish were included in the standard talloc distribution.

Definition in file talloc.h.


Data Structure Documentation

◆ fr_talloc_destructor_disarm_s

struct fr_talloc_destructor_disarm_s

Structure to record a destructor to disarm if a child talloc chunk is freed.

Provided here so that additional memory can be allocated with talloc pool.

Definition at line 101 of file talloc.h.

+ Collaboration diagram for fr_talloc_destructor_disarm_s:
Data Fields
fr_talloc_destructor_t * d Destructor to disarm.

◆ fr_talloc_destructor_s

struct fr_talloc_destructor_s

Structure to record a destructor operation on a specific talloc chunk.

Provided here so that additional memory can be allocated with talloc pool.

Definition at line 89 of file talloc.h.

+ Collaboration diagram for fr_talloc_destructor_s:
Data Fields
fr_talloc_destructor_disarm_t * ds Chunk to free.
void * fire Parent chunk.
fr_talloc_free_func_t func Free function.
void * uctx uctx to pass to free function.

Macro Definition Documentation

◆ talloc_autofree_context

#define talloc_autofree_context   talloc_autofree_context_global

The original function is deprecated, so replace it with our version.

Definition at line 51 of file talloc.h.

◆ talloc_foreach

#define talloc_foreach (   _array,
  _iter 
)
Value:
for (__typeof__(_array[0]) _iter, *_p = (void *)(_array), *_end = _array ? (void *)((_array) + talloc_array_length(_array)) : NULL; \
(_p < _end) && (_iter = *((void **)(uintptr_t)(_p))); \
_p = (__typeof__(_p))((__typeof__(_array))_p) + 1)

Iterate over a talloced array of elements.

talloc_foreach(vpt_m, vpt) {
        tmpl_debug(vpt);
}

There seems to be a limitation in for loop initialiser arguments where they all must be the same type, though we can control the number of layers of pointer indirection on a per variable basis.

We declare _p to be a pointer of the specified _type, and initialise it to the start of the array. We declare _end to be a pointer of the specified type and initialise it to point to the end of the array using talloc_array_length().

_iter is only updated in the condition to avoid de-referencing invalid memory.

Parameters
[in]_arrayto iterate over. May contain zero elements.
[in]_iterName of iteration variable. Will be declared in the scope of the loop.

Definition at line 75 of file talloc.h.

◆ talloc_get_type_abort_const

#define talloc_get_type_abort_const   talloc_get_type_abort

Definition at line 270 of file talloc.h.

◆ talloc_list_free

#define talloc_list_free (   _head)    _talloc_list_free((void **)_head, offsetof(__typeof__(**(_head)), next))

Free a list of talloced structures containing a next field.

Parameters
[in]_headof list to free. Will set memory it points to to be NULL.

Definition at line 223 of file talloc.h.

◆ talloc_list_get_type_abort

#define talloc_list_get_type_abort (   _head,
  _type 
)    (_type *)_talloc_list_get_type_abort(_head, offsetof(__typeof__(*(_head)), next), #_type, __location__)

Verify a list of talloced structures are the correct type and are still valid.

Parameters
[in]_headof list to check.
[in]_typeof talloced chunk we expect.

Definition at line 243 of file talloc.h.

◆ talloc_pooled_object

#define talloc_pooled_object (   _ctx,
  _type,
  _num_subobjects,
  _total_subobjects_size 
)     talloc(_ctx, _type)

Definition at line 168 of file talloc.h.

◆ talloc_zero_pooled_object

#define talloc_zero_pooled_object (   _ctx,
  _type,
  _num_subobjects,
  _total_subobjects_size 
)     talloc_zero(_ctx, _type)

Definition at line 165 of file talloc.h.

Typedef Documentation

◆ fr_talloc_destructor_disarm_t

Definition at line 80 of file talloc.h.

◆ fr_talloc_destructor_t

Definition at line 80 of file talloc.h.

◆ fr_talloc_free_func_t

typedef int(* fr_talloc_free_func_t) (void *fire_ctx, void *uctx)

Definition at line 80 of file talloc.h.

◆ TALLOC_CHILD_CTX

Definition at line 284 of file talloc.h.

Function Documentation

◆ _talloc_list_free()

static void _talloc_list_free ( void **  head,
size_t  offset 
)
inlinestatic

Definition at line 225 of file talloc.h.

+ Here is the call graph for this function:

◆ _talloc_list_get_type_abort()

static void* _talloc_list_get_type_abort ( void *  head,
size_t  offset,
char const *  type,
char const *  location 
)
inlinestatic

Definition at line 244 of file talloc.h.

◆ talloc_aligned_array()

TALLOC_CTX* talloc_aligned_array ( TALLOC_CTX *  ctx,
void **  start,
size_t  alignment,
size_t  size 
)

Return a page aligned talloc memory array.

Because we can't intercept talloc's malloc() calls, we need to do some tricks in order to get the first allocation in the array page aligned, and to limit the size of the array to a multiple of the page size.

The reason for wanting a page aligned talloc array, is it allows us to mprotect() the pages that belong to the array.

Talloc chunks appear to be allocated within the protected region, so this should catch frees too.

Parameters
[in]ctxto allocate array memory in.
[out]startThe first aligned address in the array.
[in]alignmentWhat alignment the memory chunk should have.
[in]sizeHow big to make the array. Will be corrected to a multiple of the page size. The actual array size will be size rounded to a multiple of the (page_size), + page_size
Returns
  • A talloc chunk on success.
  • NULL on failure.

Definition at line 196 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_array_concat()

fr_slen_t talloc_array_concat ( fr_sbuff_t out,
char const *const *  array,
char const *  sep 
)

Concat an array of strings (not NULL terminated), with a string separator.

Parameters
[out]outWhere to write the resulting string.
[in]arrayof strings to concat.
[in]septo insert between elements. May be NULL.
Returns
  • >= 0 on success - length of the string created.
  • <0 on failure. How many bytes we would need.

Definition at line 802 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_array_null_strip()

void** talloc_array_null_strip ( void **  array)

Remove a NULL termination pointer from an array of pointers.

If the end of the array is not NULL, NULL will be returned (error).

Parameters
[in]arrayto null strip. Will be invalidated (realloced).
Returns
  • NULL if array is NULL, if terminating element is not NULL, or reallocation fails.
  • A realloced version of array without the terminating NULL element.

Definition at line 770 of file talloc.c.

◆ talloc_array_null_terminate()

void** talloc_array_null_terminate ( void **  array)

Add a NULL pointer to an array of pointers.

This is needed by some 3rd party libraries which take NULL terminated arrays for arguments.

If allocation fails, NULL will be returned and the original array will not be touched.

Parameters
[in]arrayto null terminate. Will be invalidated (realloced).
Returns
  • NULL if array is NULL, or if reallocation fails.
  • A realloced version of array with an additional NULL element.

Definition at line 740 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_autofree_context_global()

TALLOC_CTX* talloc_autofree_context_global ( void  )

Definition at line 845 of file talloc.c.

+ Here is the call graph for this function:

◆ talloc_autofree_context_thread_local()

TALLOC_CTX* talloc_autofree_context_thread_local ( void  )

Get a thread-safe autofreed ctx that will be freed when the thread or process exits.

Note
This should be used in place of talloc_autofree_context (which is now deprecated)
Will not be thread-safe if NULL tracking is enabled.
Returns
A talloc ctx which will be freed when the thread or process exits.

Definition at line 876 of file talloc.c.

+ Here is the call graph for this function:

◆ talloc_bstr_append()

char* talloc_bstr_append ( TALLOC_CTX *  ctx,
char *  to,
char const *  from,
size_t  from_len 
)

Append a bstr to a bstr.

Parameters
[in]ctxto allocated.
[in]tostring to append to.
[in]fromstring to append from.
[in]from_lenLength of from.
Returns
  • Realloced buffer containing both to and from.
  • NULL on failure. To will still be valid.

Definition at line 480 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_bstr_realloc()

char* talloc_bstr_realloc ( TALLOC_CTX *  ctx,
char *  in,
size_t  inlen 
)

Trim a bstr (char) buffer.

Reallocs to inlen + 1 and '\0' terminates the string buffer.

Parameters
[in]ctxto realloc buffer into.
[in]instring to trim. Will be invalid after this function returns. If NULL a new zero terminated buffer of inlen bytes will be allocated.
[in]inlenLength to trim string to.
Returns
  • The realloced string on success. in then points to invalid memory.
  • NULL on failure. In will still be valid.

Definition at line 516 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_bstrdup()

char* talloc_bstrdup ( TALLOC_CTX *  ctx,
char const *  in 
)

Binary safe strdup function.

Parameters
[in]ctxthe talloc context to allocate new buffer in.
[in]inString to dup, may contain embedded '\0'.
Returns
duped string.

Definition at line 424 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_bstrndup()

char* talloc_bstrndup ( TALLOC_CTX *  ctx,
char const *  in,
size_t  inlen 
)

Binary safe strndup function.

Parameters
[in]ctxhe talloc context to allocate new buffer in.
[in]inString to dup, may contain embedded '\0'.
[in]inlenNumber of bytes to dup.
Returns
duped string.

Definition at line 452 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_buffer_append_buffer()

char* talloc_buffer_append_buffer ( TALLOC_CTX *  ctx,
char *  to,
char const *  from 
)

Concatenate to + from.

Parameters
[in]ctxto allocate realloced buffer in.
[in]totalloc string buffer to append to.
[in]fromtalloc string buffer to append.
Returns
  • NULL if to or from are NULL or if the realloc fails. Note: You'll still need to free to if this function returns NULL.
  • The concatenation of to + from. After this function returns to may point to invalid memory and should not be used.

Definition at line 548 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_buffer_append_variadic_buffer()

char* talloc_buffer_append_variadic_buffer ( TALLOC_CTX *  ctx,
char *  to,
int  argc,
  ... 
)

Concatenate to + ...

Parameters
[in]ctxto allocate realloced buffer in.
[in]totalloc string buffer to append to.
[in]argchow many variadic arguments were passed.
[in]...talloc string buffer(s) to append. Arguments can be NULL to simplify calling logic.
Returns
  • NULL if to or from are NULL or if the realloc fails. Note: You'll still need to free to if this function returns NULL.
  • The concatenation of to + from. After this function returns to may point to invalid memory and should not be used.

Definition at line 584 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_child_ctx_alloc()

TALLOC_CHILD_CTX* talloc_child_ctx_alloc ( TALLOC_CHILD_CTX parent)

Allocate a TALLOC_CHILD_CTX from a parent.

Definition at line 940 of file talloc.c.

◆ talloc_child_ctx_init()

TALLOC_CHILD_CTX* talloc_child_ctx_init ( TALLOC_CTX *  ctx)

Allocate and initialize a TALLOC_CHILD_CTX.

The TALLOC_CHILD_CTX ensures ordering for allocators and destructors. When a TALLOC_CHILD_CTX is created, it is added to parent, in LIFO order. In contrast, the basic talloc operations do not guarantee any kind of order.

When the TALLOC_CHILD_CTX is freed, the children are freed in FILO order. That process ensures that the children are freed before the parent, and that the younger siblings are freed before the older siblings.

The idea is that if we have an initializer for A, which in turn initializes B and C. When the memory is freed, we should do the operations in the reverse order.

Definition at line 926 of file talloc.c.

+ Here is the call graph for this function:

◆ talloc_const_free()

static int talloc_const_free ( void const *  ptr)
inlinestatic

Free const'd memory.

Parameters
[in]ptrto free.

Definition at line 212 of file talloc.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_decrease_ref_count()

int talloc_decrease_ref_count ( void const *  ptr)

Decrease the reference count on a ptr.

Ptr will be freed if count reaches zero.

This is equivalent to talloc 1.0 behaviour of talloc_free.

Parameters
ptrto decrement ref count for.
Returns
  • 0 The memory was freed.
  • >0 How many references remain.

Definition at line 708 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_destructor_add()

fr_talloc_destructor_t* talloc_destructor_add ( TALLOC_CTX *  fire_ctx,
TALLOC_CTX *  disarm_ctx,
fr_talloc_free_func_t  func,
void const *  uctx 
)

Add an additional destructor to a talloc chunk.

Parameters
[in]fire_ctxWhen this ctx is freed the destructor function will be called.
[in]disarm_ctxWhen this ctx is freed the destructor will be disarmed. May be NULL. talloc_destructor_disarm may be used to disarm the destructor too.
[in]functo call when the fire_ctx is freed.
[in]uctxdata to pass to the above function.
Returns
  • A handle to access the destructor on success.
  • NULL on failure.

Definition at line 96 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_destructor_disarm()

void talloc_destructor_disarm ( fr_talloc_destructor_t d)

Disarm a destructor and free all memory allocated in the trigger ctxs.

Definition at line 138 of file talloc.c.

+ Here is the call graph for this function:

◆ talloc_free_data()

void talloc_free_data ( void *  data)

A wrapper that can be passed to tree or hash alloc functions that take a fr_free_t.

Definition at line 37 of file talloc.c.

+ Here is the call graph for this function:

◆ talloc_init_const()

static TALLOC_CTX* talloc_init_const ( char const *  name)
inlinestatic

Allocate a top level chunk with a constant name.

Parameters
[in]nameMust be a string literal.
Returns
  • NULL on allocation error.
  • A new talloc chunk on success.

Definition at line 112 of file talloc.h.

+ Here is the caller graph for this function:

◆ talloc_link_ctx()

int talloc_link_ctx ( TALLOC_CTX *  parent,
TALLOC_CTX *  child 
)

Link two different parent and child contexts, so the child is freed before the parent.

Note
This is not thread safe. Do not free parent before threads are joined, do not call from a child thread.
Parameters
parentwho's fate the child should share.
childbound to parent's lifecycle.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 167 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_memcmp_array()

int talloc_memcmp_array ( uint8_t const *  a,
uint8_t const *  b 
)

Compares two talloced uint8_t arrays with memcmp.

Talloc arrays carry their length as part of the structure, so can be passed to a generic comparison function.

Parameters
aPointer to first array.
bPointer to second array.
Returns
  • 0 if the arrays match.
  • a positive or negative integer otherwise.

Definition at line 660 of file talloc.c.

◆ talloc_memcmp_bstr()

int talloc_memcmp_bstr ( char const *  a,
char const *  b 
)

Compares two talloced char arrays with memcmp.

Talloc arrays carry their length as part of the structure, so can be passed to a generic comparison function.

Parameters
aPointer to first array.
bPointer to second array.
Returns
  • 0 if the arrays match.
  • a positive or negative integer otherwise.

Definition at line 684 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_null_ctx()

void* talloc_null_ctx ( void  )

Retrieve the current talloc NULL ctx.

Talloc doesn't provide a function to retrieve the top level memory tracking context. This function does that...

Returns
the current talloc NULL context or NULL if memory tracking is not enabled.

Definition at line 49 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_page_aligned_pool()

TALLOC_CTX* talloc_page_aligned_pool ( TALLOC_CTX *  ctx,
void **  start,
void **  end,
size_t  size 
)

Return a page aligned talloc memory pool.

Because we can't intercept talloc's malloc() calls, we need to do some tricks in order to get the first allocation in the pool page aligned, and to limit the size of the pool to a multiple of the page size.

The reason for wanting a page aligned talloc pool, is it allows us to mprotect() the pages that belong to the pool.

Talloc chunks appear to be allocated within the protected region, so this should catch frees too.

Parameters
[in]ctxto allocate pool memory in.
[out]startA page aligned address within the pool. This can be passed to mprotect().
[out]endof the pages that should be protected.
[in]sizeHow big to make the pool. Will be corrected to a multiple of the page size. The actual pool size will be size rounded to a multiple of the (page_size), + page_size

Definition at line 239 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_strlen()

static size_t talloc_strlen ( char const *  s)
inlinestatic

Returns the length of a talloc array containing a string.

Parameters
[in]sto return the length of.

Definition at line 277 of file talloc.h.

+ Here is the caller graph for this function:

◆ talloc_typed_asprintf()

char* talloc_typed_asprintf ( TALLOC_CTX *  ctx,
char const *  fmt,
  ... 
)

Call talloc vasprintf, setting the type on the new chunk correctly.

For some bizarre reason the talloc string functions don't set the memory chunk type to char, which causes all kinds of issues with verifying fr_pair_ts.

Parameters
[in]ctxThe talloc context to hang the result off.
[in]fmtThe format string.
Returns
  • Formatted string.
  • NULL on error.

Definition at line 380 of file talloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ talloc_typed_memdup()

uint8_t* talloc_typed_memdup ( TALLOC_CTX *  ctx,
uint8_t const *  in,
size_t  inlen 
)

Call talloc_memdup, setting the type on the new chunk correctly.

Parameters
[in]ctxThe talloc context to hang the result off.
[in]inThe data you want to duplicate.
[in]inlenthe length of the data to be duplicated.
Returns
  • Duplicated data.
  • NULL on error.

Definition at line 308 of file talloc.c.

◆ talloc_typed_strdup()

char* talloc_typed_strdup ( TALLOC_CTX *  ctx,
char const *  p 
)

Call talloc_strdup, setting the type on the new chunk correctly.

For some bizarre reason the talloc string functions don't set the memory chunk type to char, which causes all kinds of issues with verifying fr_pair_ts.

Parameters
[in]ctxThe talloc context to hang the result off.
[in]pThe string you want to duplicate.
Returns
  • Duplicated string.
  • NULL on error.

Definition at line 333 of file talloc.c.

◆ talloc_typed_strdup_buffer()

char* talloc_typed_strdup_buffer ( TALLOC_CTX *  ctx,
char const *  p 
)

Call talloc_strndup, setting the type on the new chunk correctly.

This function is similar to talloc_typed_strdup but gets the chunk length using talloc functions.

Parameters
[in]ctxThe talloc context to hang the result off.
[in]pThe string you want to duplicate.
Returns
  • Duplicated string.
  • NULL on error.

Definition at line 357 of file talloc.c.

+ Here is the caller graph for this function:

◆ talloc_typed_vasprintf()

char* talloc_typed_vasprintf ( TALLOC_CTX *  ctx,
char const *  fmt,
va_list  ap 
)

Call talloc vasprintf, setting the type on the new chunk correctly.

For some bizarre reason the talloc string functions don't set the memory chunk type to char, which causes all kinds of issues with verifying fr_pair_ts.

Parameters
[in]ctxThe talloc context to hang the result off.
[in]fmtThe format string.
[in]apvaradic arguments.
Returns
  • Formatted string.
  • NULL on error.

Definition at line 407 of file talloc.c.

+ Here is the caller graph for this function: