talloc_array(3)
π¦ tally-ho, bestie β it's talloc_array(3)
okay so this is the talloc manual page, babes β talloc, the manual name, is right there in the title and it's giving "we're in the talloc girlies' section of the man pages" β¨
π NAME π
talloc_array β the talloc array functions, periodt π
- Talloc contains some handy helpers for handling Arrays conveniently. fr fr, that's the whole vibe.
β¨ SYNOPSIS β¨
πΈ Modules
The talloc string functions β talloc string allocation and manipulation functions.
π«Ά Functions
_PUBLIC_ void * talloc_array (const void *ctx, #type, unsigned count)β allocate an array π_PUBLIC_ void * talloc_array_size (const void *ctx, size_t size, unsigned count)β allocate an array (yes, again, iconic)void * talloc_array_ptrtype (const void *ctx, const void *ptr, unsigned count)β allocate an array into a typed pointer πsize_t talloc_array_length (const void *ctx)β get the number of elements in a talloc'ed array πvoid * talloc_zero_array (const void *ctx, #type, unsigned count)β allocate a zero-initialized array π§_PUBLIC_ void * talloc_realloc (const void *ctx, void *ptr, #type, size_t count)β change the size of a talloc array π₯_PUBLIC_ void * talloc_realloc_zero (const void *ctx, void *ptr, size_t count)β change the size of a talloc array, zero out additional space βvoid * talloc_realloc_size (const void *ctx, void *ptr, size_t size)β untyped realloc to change the size of a talloc array π_PUBLIC_ void * talloc_realloc_fn (const void *context, void *ptr, size_t size)β provide a function version oftalloc_realloc_sizeπ
π Detailed Description π
Talloc contains some handy helpers for handling Arrays conveniently. That's it, that's the tea π
π Function Documentation π
π¦ _PUBLIC_ void* talloc_array (const void * ctx, # type, unsigned count)
Allocate an array, bestie. The macro is equivalent to:
(type *)talloc_size(ctx, sizeof(type) * count);
except that it provides integer overflow protection for the multiply, returning NULL if the multiply overflows. so like, she's got your back π
Parameters
ctxβ The talloc context to hang the result off.typeβ The type that we want to allocate.countβ The number of 'type' elements you want to allocate.
Returns
The allocated result, properly cast to 'type *', NULL on error.
Example
unsigned int *a, *b;
a = talloc_zero(NULL, unsigned int);
b = talloc_array(a, unsigned int, 100);
See also
talloc()
talloc_zero_array()
π size_t talloc_array_length (const void * ctx)
Get the number of elements in a talloc'ed array. A talloc chunk carries its own size, so for talloc'ed arrays it is not necessary to store the number of elements explicitly β she already knows her own length, main character energy π
Parameters
ctxβ The allocated array.
Returns
The number of elements in ctx.
π§ void* talloc_array_ptrtype (const void * ctx, const void * ptr, unsigned count)
Allocate an array into a typed pointer. The macro should be used when you have a pointer to an array and want to allocate memory of an array to point at with this pointer. When compiling with gcc >= 3 it is typesafe. Note this is a wrapper of talloc_array_size() and talloc_get_name() will return the current location in the source file and not the type β so don't come for her about the name, okay? π
Parameters
ctxβ The talloc context to hang the result off.ptrβ The pointer you want to assign the result to.countβ The number of elements you want to allocate.
Returns
The allocated memory chunk, properly casted. NULL on error.
π _PUBLIC_ void* talloc_array_size (const void * ctx, size_t size, unsigned count)
Allocate an array. short and sweet, we love her β¨
Parameters
ctxβ The talloc context to hang the result off.sizeβ The size of an array element.countβ The number of elements you want to allocate.
Returns
The allocated result, NULL on error.
π₯ _PUBLIC_ void* talloc_realloc (const void * ctx, void * ptr, # type, size_t count)
Change the size of a talloc array. The macro changes the size of a talloc pointer. The 'count' argument is the number of elements of type 'type' that you want the resulting pointer to hold. glow-up for your array, literally π
talloc_realloc() has the following equivalences:
talloc_realloc(ctx, NULL, type, 1) ==> talloc(ctx, type);
talloc_realloc(ctx, NULL, type, N) ==> talloc_array(ctx, type, N);
talloc_realloc(ctx, ptr, type, 0) ==> talloc_free(ptr);
The 'context' argument is only used if 'ptr' is NULL, otherwise it is ignored. noted π«Ά
Parameters
ctxβ The parent context used ifptrisNULL.ptrβ The chunk to be resized.typeβ The type of the array element insideptr.countβ The intended number of array elements.
Returns
The new array, NULL on error. The call will fail either due to a lack of memory, or because the pointer has more than one parent (see talloc_reference()). so if it flops, that's why π
π _PUBLIC_ void* talloc_realloc_fn (const void * context, void * ptr, size_t size)
Provide a function version of talloc_realloc_size. This is a non-macro version of talloc_realloc(), which is useful as libraries sometimes want a ralloc function pointer. A realloc() implementation encapsulates the functionality of malloc(), free() and realloc() in one call, which is why it is useful to be able to pass around a single function pointer. one function, three jobs, she's booked and busy π
Parameters
contextβ The parent context used ifptrisNULL.ptrβ The chunk to be resized.sizeβ The new chunk size.
Returns
The new chunk, NULL on error.
π void* talloc_realloc_size (const void * ctx, void * ptr, size_t size)
Untyped realloc to change the size of a talloc array. The macro is useful when the type is not known so the typesafe talloc_realloc() cannot be used. for when the type is a mystery, iykyk π΅οΈββοΈ
Parameters
ctxβ The parent context used if'ptr'isNULL.ptrβ The chunk to be resized.sizeβ The new chunk size.
Returns
The new array, NULL on error.
β _PUBLIC_ void* talloc_realloc_zero (const void * ctx, void * ptr, size_t count)
Change the size of a talloc array, zero out additional space. Same as talloc_realloc() with the additional behavior to zero out code in case the array is expanded. fresh clean zeros, no cap πΈ
heads up bestie: the parameter list below literally includes type, even though the signature above doesn't have one. we're just reporting the facts, we don't make the rules π
Parameters
ctxβ The parent context used ifptrisNULL.ptrβ The chunk to be resized.typeβ The type of the array element insideptr.countβ The intended number of array elements.
Returns
The new array, NULL on error. The call will fail either due to a lack of memory, or because the pointer has more than one parent (see talloc_reference()).
π void* talloc_zero_array (const void * ctx, # type, unsigned count)
Allocate a zero-initialized array. squeaky clean, obsessed π
Parameters
ctxβ The talloc context to hang the result off.typeβ The type that we want to allocate.countβ The number of 'type' elements you want to allocate.
Returns
The allocated result casted to 'type *', NULL on error.
The talloc_zero_array() macro is equivalent to:
ptr = talloc_array(ctx, type, count);
if (ptr) memset(ptr, 0, sizeof(type) * count);
π«Ά Author π«Ά
Generated automatically by Doxygen for talloc from the source code. not a human, just a robot doing her little thing π€π
and that's the whole page, bestie! this little beauty is Version 2.0, dated Wed May 13 2026, and it lives its best life under the name talloc_array(3) β see you in the man pages, muah ππβ¨
π¦ where this page comes from
- centos-stream 9: libtalloc-devel 2.4.4-1.el9 Β· LGPL-3.0-or-later
- centos-stream 9: libtalloc-devel 2.4.4-1.el9 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms