25RCSIDH(talloc_h, 
"$Id: cc810bf1723d6429e084bd549252295d90f067c5 $")
 
   35#ifdef HAVE_WDOCUMENTATION 
   39#ifdef HAVE_WDOCUMENTATION 
   43#include <freeradius-devel/autoconf.h>   
   44#include <freeradius-devel/build.h> 
   45#include <freeradius-devel/missing.h> 
   46#include <freeradius-devel/util/sbuff.h> 
   48#undef talloc_autofree_context 
   51#define talloc_autofree_context talloc_autofree_context_global 
   75#define talloc_foreach(_array, _iter) \ 
   76        for (__typeof__(_array[0]) _iter, *_p = (void *)(_array), *_end = _array ? (void *)((_array) + talloc_array_length(_array)) : NULL; \ 
   77             (_p < _end) && (_iter = *((void **)(uintptr_t)(_p))); \ 
   78             _p = (__typeof__(_p))((__typeof__(_array))_p) + 1) 
 
  116        ctx = talloc_new(NULL);
 
  119        talloc_set_name_const(ctx, 
name);
 
 
  132        for (p = str, q = p + (talloc_array_length(str) - 1); p < q; p++) *p = tolower((
uint8_t) *p);
 
 
  147TALLOC_CTX      *
talloc_page_aligned_pool(TALLOC_CTX *ctx, 
void **start, 
size_t *end_len, 
unsigned int headers, 
size_t size);
 
  153#if defined(HAVE__TALLOC_POOLED_OBJECT) && defined(talloc_pooled_object) 
  154#  define HAVE_TALLOC_ZERO_POOLED_OBJECT        1 
  155#  define HAVE_TALLOC_POOLED_OBJECT             1 
  157#  define       talloc_zero_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size) \ 
  158                (_type *)_talloc_zero_pooled_object((_ctx), sizeof(_type), #_type, \ 
  159                                                    (_num_subobjects), (_total_subobjects_size)) 
  161static inline TALLOC_CTX *_talloc_zero_pooled_object(
const void *ctx,
 
  163                                                     const char *type_name,
 
  164                                                     unsigned num_subobjects,
 
  165                                                     size_t total_subobjects_size)
 
  168        new = _talloc_pooled_object(ctx, type_size, type_name, num_subobjects, total_subobjects_size);
 
  170        memset(
new, 0, type_size);
 
  177#  define       talloc_zero_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size) \ 
  178                talloc_zero(_ctx, _type) 
 
  179#undef talloc_pooled_object 
  180#  define       talloc_pooled_object(_ctx, _type, _num_subobjects, _total_subobjects_size) \ 
 
  186#define talloc_realloc_zero(_ctx, _ptr, _type, _count) \ 
  187    (_type *)_talloc_realloc_zero((_ctx), (_ptr), sizeof(_type), _count, #_type) 
 
  204char            *
talloc_bstr_append(TALLOC_CTX *ctx, 
char *to, 
char const *from, 
size_t from_len);
 
  241#ifdef TALLOC_GET_TYPE_ABORT_NOOP 
  242#  define talloc_get_type_abort_const(ptr, type) (const type *)(ptr) 
  244#  define talloc_get_type_abort_const talloc_get_type_abort 
  254        return talloc_array_length(our_s) - 1;
 
 
static int const char * fmt
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
Functions which we wish were included in the standard talloc distribution.
void ** talloc_array_null_terminate(void **array)
Add a NULL pointer to an array of pointers.
char * talloc_bstrdup(TALLOC_CTX *ctx, char const *in)
Binary safe strdup function.
#define talloc_get_type_abort_const
TALLOC_CHILD_CTX * talloc_child_ctx_alloc(TALLOC_CHILD_CTX *parent)
Allocate a TALLOC_CHILD_CTX from a parent.
static int talloc_const_free(void const *ptr)
Free const'd memory.
char * talloc_typed_asprintf(TALLOC_CTX *ctx, char const *fmt,...))
Call talloc vasprintf, setting the type on the new chunk correctly.
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.
char * talloc_typed_strdup_buffer(TALLOC_CTX *ctx, char const *p)
Call talloc_strndup, setting the type on the new chunk correctly.
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.
ssize_t talloc_hdr_size(void)
Calculate the size of the talloc chunk header.
TALLOC_CTX * talloc_autofree_context_global(void)
TALLOC_CHILD_CTX * talloc_child_ctx_init(TALLOC_CTX *ctx)
Allocate and initialize a TALLOC_CHILD_CTX.
int talloc_memcmp_array(uint8_t const *a, uint8_t const *b)
Compares two talloced uint8_t arrays with memcmp.
char * talloc_buffer_append_variadic_buffer(TALLOC_CTX *ctx, char *to, int argc,...)
Concatenate to + ...
void * _talloc_realloc_zero(const void *ctx, void *ptr, size_t elem_size, unsigned count, const char *name)
Version of talloc_realloc which zeroes out freshly allocated memory.
char * talloc_bstr_realloc(TALLOC_CTX *ctx, char *in, size_t inlen)
Trim a bstr (char) buffer.
fr_talloc_free_func_t func
Free function.
static TALLOC_CTX * talloc_init_const(char const *name)
Allocate a top level chunk with a constant name.
TALLOC_CTX * talloc_aligned_array(TALLOC_CTX *ctx, void **start, size_t alignment, size_t size)
Return a page aligned talloc memory array.
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.
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.
char * talloc_bstrndup(TALLOC_CTX *ctx, char const *in, size_t inlen)
Binary safe strndup function.
void * talloc_null_ctx(void)
Retrieve the current talloc NULL ctx.
fr_talloc_destructor_t * d
Destructor to disarm.
TALLOC_CTX * talloc_page_aligned_pool(TALLOC_CTX *ctx, void **start, size_t *end_len, unsigned int headers, size_t size)
Return a page aligned talloc memory pool.
char * talloc_typed_strdup(TALLOC_CTX *ctx, char const *p)
Call talloc_strdup, setting the type on the new chunk correctly.
void talloc_free_data(void *data)
A wrapper that can be passed to tree or hash alloc functions that take a fr_free_t.
int talloc_decrease_ref_count(void const *ptr)
Decrease the reference count on a ptr.
TALLOC_CTX * talloc_autofree_context_thread_local(void)
Get a thread-safe autofreed ctx that will be freed when the thread or process exits.
void * uctx
uctx to pass to free function.
char * talloc_buffer_append_buffer(TALLOC_CTX *ctx, char *to, char const *from)
Concatenate to + from.
void ** talloc_array_null_strip(void **array)
Remove a NULL termination pointer from an array of pointers.
char * talloc_bstr_append(TALLOC_CTX *ctx, char *to, char const *from, size_t from_len)
Append a bstr to a bstr.
void talloc_destructor_disarm(fr_talloc_destructor_t *d)
Disarm a destructor and free all memory allocated in the trigger ctxs.
int(* fr_talloc_free_func_t)(void *fire_ctx, void *uctx)
static void talloc_bstr_tolower(char *str)
Convert a talloced string to lowercase.
fr_talloc_destructor_disarm_t * ds
Chunk to free.
static size_t talloc_strlen(char const *s)
Returns the length of a talloc array containing a string.
char * talloc_typed_vasprintf(TALLOC_CTX *ctx, char const *fmt, va_list ap))
Call talloc vasprintf, setting the type on the new chunk correctly.
int talloc_memcmp_bstr(char const *a, char const *b)
Compares two talloced char arrays with memcmp.
Structure to record a destructor to disarm if a child talloc chunk is freed.
Structure to record a destructor operation on a specific talloc chunk.
static size_t char fr_sbuff_t size_t inlen
static size_t char ** out