Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Go to the source code of this file.
Data Structures | |
struct | ast_string_field_mgr |
struct | ast_string_field_pool |
struct | ast_string_field_vector |
Macros | |
#define | __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, file, lineno, func) |
#define | ast_calloc_with_stringfields(n, type, size) |
Allocate a structure with embedded stringfields in a single allocation. More... | |
#define | AST_DECLARE_STRING_FIELDS(field_list) |
Declare the fields needed in a structure. More... | |
#define | AST_STRING_FIELD(name) const ast_string_field name |
Declare a string field. More... | |
#define | AST_STRING_FIELD_ALLOCATION(x) *((ast_string_field_allocation *) (x - __alignof__(ast_string_field_allocation))) |
Macro to provide access to the allocation field that lives immediately in front of a string field. More... | |
#define | ast_string_field_build(x, field, fmt, args...) |
Set a field to a complex (built) value. More... | |
#define | ast_string_field_build_va(x, field, fmt, args) |
Set a field to a complex (built) value. More... | |
#define | AST_STRING_FIELD_EXTENDED(name) AST_STRING_FIELD(name) |
Declare an extended string field. More... | |
#define | ast_string_field_free_memory(x) |
free all memory - to be called before destroying the object More... | |
#define | ast_string_field_init(x, size) |
Initialize a field pool and fields. More... | |
#define | ast_string_field_init_extended(x, field) |
Initialize an extended string field. More... | |
#define | ast_string_field_ptr_build(x, ptr, fmt, args...) |
Set a field to a complex (built) value. More... | |
#define | ast_string_field_ptr_build_va(x, ptr, fmt, args) |
Set a field to a complex (built) value with prebuilt va_lists. More... | |
#define | ast_string_field_ptr_set(x, ptr, data) |
Set a field to a simple string value. More... | |
#define | ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_string_field_set(x, field, data) |
Set a field to a simple string value. More... | |
#define | ast_string_fields_cmp(instance1, instance2) |
Compare the string fields in two instances of the same structure. More... | |
#define | ast_string_fields_copy(copy, orig) |
Copy all string fields from one instance to another of the same structure. More... | |
Typedefs | |
typedef const char * | ast_string_field |
typedef uint16_t | ast_string_field_allocation |
Enumerations | |
enum | ast_stringfield_cleanup_type { AST_STRINGFIELD_RESET = 0 , AST_STRINGFIELD_DESTROY = -1 } |
Functions | |
void * | __ast_calloc_with_stringfields (unsigned int num_structs, size_t struct_size, size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size, const char *file, int lineno, const char *func) |
ast_string_field | __ast_string_field_alloc_space (struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, size_t needed, const char *file, int lineno, const char *func) |
int | __ast_string_field_free_memory (struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, enum ast_stringfield_cleanup_type cleanup_type, const char *file, int lineno, const char *func) |
Internal cleanup function. More... | |
int | __ast_string_field_init (struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, int needed, const char *file, int lineno, const char *func) |
Internal initialization function. More... | |
void | __ast_string_field_ptr_build (const char *file, int lineno, const char *func, struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, ast_string_field *ptr, const char *format,...) |
void | __ast_string_field_ptr_build_va (struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, ast_string_field *ptr, const char *format, va_list ap, const char *file, int lineno, const char *func) |
int | __ast_string_field_ptr_grow (struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head, size_t needed, const ast_string_field *ptr) |
void | __ast_string_field_release_active (struct ast_string_field_pool *pool_head, const ast_string_field ptr) |
int | __ast_string_fields_cmp (struct ast_string_field_vector *left, struct ast_string_field_vector *right) |
int | __ast_string_fields_copy (struct ast_string_field_pool *copy_pool, struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr, const char *file, int lineno, const char *func) |
Variables | |
const char * | __ast_string_field_empty |
#define __ast_string_field_ptr_set_by_fields | ( | field_mgr_pool, | |
field_mgr, | |||
ptr, | |||
data, | |||
file, | |||
lineno, | |||
func | |||
) |
Definition at line 484 of file stringfields.h.
#define ast_calloc_with_stringfields | ( | n, | |
type, | |||
size | |||
) |
Allocate a structure with embedded stringfields in a single allocation.
n | Current implementation only allows 1 structure to be allocated |
type | The type of structure to allocate |
size | The number of bytes of space (minimum) to allocate for stringfields to use in each structure |
This function will allocate memory for one or more structures that use stringfields, and also allocate space for the stringfields and initialize the stringfield management structure embedded in the outer structure.
Definition at line 432 of file stringfields.h.
#define AST_DECLARE_STRING_FIELDS | ( | field_list | ) |
Declare the fields needed in a structure.
field_list | The list of fields to declare, using AST_STRING_FIELD() for each one. Internally, string fields are stored as a pointer to the head of the pool, followed by individual string fields, and then a struct ast_string_field_mgr which describes the space allocated. We split the two variables so they can be used as markers around the field_list, and this allows us to determine how many entries are in the field, and play with them. In particular, for writing to the fields, we rely on __field_mgr_pool to be a non-const pointer, so we know it has the same size as ast_string_field, and we can use it to locate the fields. |
Definition at line 341 of file stringfields.h.
#define AST_STRING_FIELD | ( | name | ) | const ast_string_field name |
Declare a string field.
name | The field name |
Definition at line 303 of file stringfields.h.
#define AST_STRING_FIELD_ALLOCATION | ( | x | ) | *((ast_string_field_allocation *) (x - __alignof__(ast_string_field_allocation))) |
Macro to provide access to the allocation field that lives immediately in front of a string field.
x | Pointer to the string field |
Note that x must be a pointer to a byte-sized type – normally (char *) – or this calculation would break horribly
Definition at line 465 of file stringfields.h.
#define ast_string_field_build | ( | x, | |
field, | |||
fmt, | |||
args... | |||
) |
Set a field to a complex (built) value.
x | Pointer to a structure containing fields |
field | Name of the field to set |
fmt | printf-style format string |
args | Arguments for format string |
Definition at line 555 of file stringfields.h.
#define ast_string_field_build_va | ( | x, | |
field, | |||
fmt, | |||
args | |||
) |
Set a field to a complex (built) value.
x | Pointer to a structure containing fields |
field | Name of the field to set |
fmt | printf-style format string |
args | Arguments for format string in va_list format |
Definition at line 591 of file stringfields.h.
#define AST_STRING_FIELD_EXTENDED | ( | name | ) | AST_STRING_FIELD(name) |
Declare an extended string field.
name | The field name |
Definition at line 311 of file stringfields.h.
#define ast_string_field_free_memory | ( | x | ) |
free all memory - to be called before destroying the object
x |
Definition at line 374 of file stringfields.h.
#define ast_string_field_init | ( | x, | |
size | |||
) |
Initialize a field pool and fields.
x | Pointer to a structure containing fields |
size | Amount of storage to allocate. Use AST_STRINGFIELD_RESET to reset fields to the default value, and release all but the most recent pool. AST_STRINGFIELD_DESTROY (used internally) means free all pools which is equivalent to calling ast_string_field_free_memory. |
zero | on success |
non-zero | on failure |
Definition at line 359 of file stringfields.h.
#define ast_string_field_init_extended | ( | x, | |
field | |||
) |
Initialize an extended string field.
x | Pointer to a structure containing the field |
field | The extended field to initialize |
zero | on success |
non-zero | on error |
Definition at line 401 of file stringfields.h.
#define ast_string_field_ptr_build | ( | x, | |
ptr, | |||
fmt, | |||
args... | |||
) |
Set a field to a complex (built) value.
x | Pointer to a structure containing fields |
ptr | Pointer to a field within the structure |
fmt | printf-style format string |
args | Arguments for format string |
Definition at line 537 of file stringfields.h.
#define ast_string_field_ptr_build_va | ( | x, | |
ptr, | |||
fmt, | |||
args | |||
) |
Set a field to a complex (built) value with prebuilt va_lists.
x | Pointer to a structure containing fields |
ptr | Pointer to a field within the structure |
fmt | printf-style format string |
args | Arguments for format string in va_list format |
Definition at line 573 of file stringfields.h.
#define ast_string_field_ptr_set | ( | x, | |
ptr, | |||
data | |||
) |
Set a field to a simple string value.
x | Pointer to a structure containing fields |
ptr | Pointer to a field within the structure |
data | String value to be copied into the field |
zero | on success |
non-zero | on error |
Definition at line 475 of file stringfields.h.
#define ast_string_field_ptr_set_by_fields | ( | field_mgr_pool, | |
field_mgr, | |||
ptr, | |||
data | |||
) | __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Definition at line 510 of file stringfields.h.
#define ast_string_field_set | ( | x, | |
field, | |||
data | |||
) |
Set a field to a simple string value.
x | Pointer to a structure containing fields |
field | Name of the field to set |
data | String value to be copied into the field |
zero | on success |
non-zero | on error |
Definition at line 521 of file stringfields.h.
#define ast_string_fields_cmp | ( | instance1, | |
instance2 | |||
) |
Compare the string fields in two instances of the same structure.
instance1 | The first instance of the structure to be compared |
instance2 | The second instance of the structure to be compared |
zero | if all string fields are equal (does not compare non-string field data) |
non-zero | if the values of the string fields differ |
Definition at line 610 of file stringfields.h.
#define ast_string_fields_copy | ( | copy, | |
orig | |||
) |
Copy all string fields from one instance to another of the same structure.
copy | The instance of the structure to be copied into |
orig | The instance of the structure to be copied from |
zero | on success |
non-zero | on error |
Definition at line 630 of file stringfields.h.
typedef const char* ast_string_field |
Definition at line 190 of file stringfields.h.
typedef uint16_t ast_string_field_allocation |
Definition at line 194 of file stringfields.h.
Definition at line 313 of file stringfields.h.
void * __ast_calloc_with_stringfields | ( | unsigned int | num_structs, |
size_t | struct_size, | ||
size_t | field_mgr_offset, | ||
size_t | field_mgr_pool_offset, | ||
size_t | pool_size, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 380 of file stringfields.c.
References __ast_calloc(), __ast_string_field_empty, allocation, ast_assert, ast_free, AST_VECTOR_APPEND, AST_VECTOR_INIT, ast_string_field_mgr::embedded_pool, make_ari_stubs::file, NULL, optimal_alloc_size(), ast_string_field_pool::size, and ast_string_field_mgr::string_fields.
ast_string_field __ast_string_field_alloc_space | ( | struct ast_string_field_mgr * | mgr, |
struct ast_string_field_pool ** | pool_head, | ||
size_t | needed, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 202 of file stringfields.c.
References add_string_pool(), ast_alignof, ast_assert, ast_make_room_for, AST_STRING_FIELD_ALLOCATION, make_ari_stubs::file, ast_string_field_mgr::last_alloc, NULL, and result.
Referenced by __ast_string_field_ptr_build_va().
int __ast_string_field_free_memory | ( | struct ast_string_field_mgr * | mgr, |
struct ast_string_field_pool ** | pool_head, | ||
enum ast_stringfield_cleanup_type | cleanup_type, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Internal cleanup function.
Definition at line 103 of file stringfields.c.
References ast_string_field_pool::active, ast_free, ast_log, AST_STRINGFIELD_DESTROY, AST_STRINGFIELD_RESET, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_FREE, ast_string_field_mgr::embedded_pool, LOG_WARNING, NULL, ast_string_field_pool::prev, reset_field(), ast_string_field_mgr::string_fields, and ast_string_field_pool::used.
Referenced by __ast_string_field_init().
int __ast_string_field_init | ( | struct ast_string_field_mgr * | mgr, |
struct ast_string_field_pool ** | pool_head, | ||
int | needed, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Internal initialization function.
Definition at line 171 of file stringfields.c.
References __ast_string_field_empty, __ast_string_field_free_memory(), add_string_pool(), AST_VECTOR_APPEND, AST_VECTOR_FREE, AST_VECTOR_INIT, ast_string_field_mgr::embedded_pool, make_ari_stubs::file, ast_string_field_mgr::last_alloc, NULL, and ast_string_field_mgr::string_fields.
void __ast_string_field_ptr_build | ( | const char * | file, |
int | lineno, | ||
const char * | func, | ||
struct ast_string_field_mgr * | mgr, | ||
struct ast_string_field_pool ** | pool_head, | ||
ast_string_field * | ptr, | ||
const char * | format, | ||
... | |||
) |
Definition at line 369 of file stringfields.c.
References __ast_string_field_ptr_build_va(), and make_ari_stubs::file.
void __ast_string_field_ptr_build_va | ( | struct ast_string_field_mgr * | mgr, |
struct ast_string_field_pool ** | pool_head, | ||
ast_string_field * | ptr, | ||
const char * | format, | ||
va_list | ap, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 286 of file stringfields.c.
References __ast_string_field_alloc_space(), __ast_string_field_empty, __ast_string_field_release_active(), ast_align_for, ast_alignof, ast_assert, ast_make_room_for, AST_STRING_FIELD_ALLOCATION, available(), make_ari_stubs::file, grow(), and ast_string_field_mgr::last_alloc.
Referenced by __ast_string_field_ptr_build().
int __ast_string_field_ptr_grow | ( | struct ast_string_field_mgr * | mgr, |
struct ast_string_field_pool ** | pool_head, | ||
size_t | needed, | ||
const ast_string_field * | ptr | ||
) |
Definition at line 240 of file stringfields.c.
References AST_STRING_FIELD_ALLOCATION, grow(), and ast_string_field_mgr::last_alloc.
void __ast_string_field_release_active | ( | struct ast_string_field_pool * | pool_head, |
const ast_string_field | ptr | ||
) |
Definition at line 261 of file stringfields.c.
References __ast_string_field_empty, ast_string_field_pool::active, ast_free, AST_STRING_FIELD_ALLOCATION, ast_string_field_pool::base, NULL, ast_string_field_pool::prev, ast_string_field_pool::size, and ast_string_field_pool::used.
Referenced by __ast_string_field_ptr_build_va(), and __ast_string_fields_copy().
int __ast_string_fields_cmp | ( | struct ast_string_field_vector * | left, |
struct ast_string_field_vector * | right | ||
) |
Definition at line 424 of file stringfields.c.
References ast_assert, AST_VECTOR_GET, and AST_VECTOR_SIZE.
int __ast_string_fields_copy | ( | struct ast_string_field_pool * | copy_pool, |
struct ast_string_field_mgr * | copy_mgr, | ||
struct ast_string_field_mgr * | orig_mgr, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 441 of file stringfields.c.
References __ast_string_field_empty, __ast_string_field_ptr_set_by_fields, __ast_string_field_release_active(), ast_assert, AST_VECTOR_GET, AST_VECTOR_SIZE, make_ari_stubs::file, and ast_string_field_mgr::string_fields.
|
extern |
Definition at line 43 of file stringfields.c.
Referenced by __ast_calloc_with_stringfields(), __ast_string_field_init(), __ast_string_field_ptr_build_va(), __ast_string_field_release_active(), __ast_string_fields_copy(), AST_TEST_DEFINE(), and reset_field().