Asterisk - The Open Source Telephony Project  18.5.0
stringfields.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2006, Digium, Inc.
5  *
6  * Kevin P. Fleming <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  \page Stringfields String Fields
21  \brief String fields in structures
22 
23  This file contains objects and macros used to manage string
24  fields in structures without requiring them to be allocated
25  as fixed-size buffers or requiring individual allocations for
26  for each field.
27 
28  Using this functionality is quite simple. An example structure
29  with three fields is defined like this:
30 
31  \code
32  struct sample_fields {
33  int x1;
34  AST_DECLARE_STRING_FIELDS(
35  AST_STRING_FIELD(foo);
36  AST_STRING_FIELD(bar);
37  AST_STRING_FIELD(blah);
38  );
39  long x2;
40  };
41  \endcode
42 
43  When an instance of this structure is allocated (either statically or
44  dynamically), the fields and the pool of storage for them must be
45  initialized:
46 
47  \code
48  struct sample_fields *x;
49 
50  x = ast_calloc(1, sizeof(*x));
51  if (x == NULL || ast_string_field_init(x, 252)) {
52  if (x)
53  ast_free(x);
54  x = NULL;
55  ... handle error
56  }
57  \endcode
58 
59  Fields will default to pointing to an empty string, and will revert to
60  that when ast_string_field_set() is called with a NULL argument.
61  A string field will \b never contain NULL.
62 
63  ast_string_field_init(x, 0) will reset fields to the
64  initial value while keeping the pool allocated.
65 
66  Reading the fields is much like using 'const char * const' fields in the
67  structure: you cannot write to the field or to the memory it points to.
68 
69  Writing to the fields must be done using the wrapper macros listed below;
70  and assignments are always by value (i.e. strings are copied):
71  * ast_string_field_set() stores a simple value;
72  * ast_string_field_build() builds the string using a printf-style format;
73  * ast_string_field_build_va() is the varargs version of the above;
74  * variants of these function allow passing a pointer to the field
75  as an argument.
76 
77  \code
78  ast_string_field_set(x, foo, "infinite loop");
79  ast_string_field_set(x, foo, NULL); // set to an empty string
80  ast_string_field_ptr_set(x, &x->bar, "right way");
81 
82  ast_string_field_build(x, blah, "%d %s", zipcode, city);
83  ast_string_field_ptr_build(x, &x->blah, "%d %s", zipcode, city);
84 
85  ast_string_field_build_va(x, bar, fmt, args)
86  ast_string_field_ptr_build_va(x, &x->bar, fmt, args)
87  \endcode
88 
89  When the structure instance is no longer needed, the fields
90  and their storage pool must be freed:
91 
92  \code
93  ast_string_field_free_memory(x);
94  ast_free(x);
95  \endcode
96 
97  A new feature "Extended String Fields" has been added in 13.9.0.
98 
99  An extended field is one that is declared outside the AST_DECLARE_STRING_FIELDS
100  block but still inside the parent structure. It's most useful for extending
101  structures where adding a new string field to an existing AST_DECLARE_STRING_FIELDS
102  block would break ABI compatibility.
103 
104  Example:
105 
106  \code
107  struct original_structure_version {
108  AST_DECLARE_STRING_FIELDS(
109  AST_STRING_FIELD(foo);
110  AST_STRING_FIELD(bar);
111  );
112  int x1;
113  int x2;
114  };
115  \endcode
116 
117  Adding "blah" to the existing string fields breaks ABI compatibility because it changes
118  the offsets of x1 and x2.
119 
120  \code
121  struct new_structure_version {
122  AST_DECLARE_STRING_FIELDS(
123  AST_STRING_FIELD(foo);
124  AST_STRING_FIELD(bar);
125  AST_STRING_FIELD(blah);
126  );
127  int x1;
128  int x2;
129  };
130  \endcode
131 
132  However, adding "blah" as an extended string field to the end of the structure doesn't break
133  ABI compatibility but still allows the use of the existing pool.
134 
135  \code
136  struct new_structure_version {
137  AST_DECLARE_STRING_FIELDS(
138  AST_STRING_FIELD(foo);
139  AST_STRING_FIELD(bar);
140  );
141  int x1;
142  int x2;
143  AST_STRING_FIELD_EXTENDED(blah);
144  };
145  \endcode
146 
147  The only additional step required is to call ast_string_field_init_extended so the
148  pool knows about the new field. It must be called AFTER ast_string_field_init or
149  ast_calloc_with_stringfields. Although ast_calloc_with_stringfields is used in the
150  sample below, it's not necessary for extended string fields.
151 
152  \code
153 
154  struct new_structure_version *x = ast_calloc_with_stringfields(1, struct new_structure_version, 252);
155  if (!x) {
156  return;
157  }
158 
159  ast_string_field_init_extended(x, blah);
160  \endcode
161 
162  The new field can now be treated just like any other string field and it's storage will
163  be released with the rest of the string fields.
164 
165  \code
166  ast_string_field_set(x, foo, "infinite loop");
167  ast_stringfield_free_memory(x);
168  ast_free(x);
169  \endcode
170 
171  This completes the API description.
172 */
173 
174 #ifndef _ASTERISK_STRINGFIELDS_H
175 #define _ASTERISK_STRINGFIELDS_H
176 
177 #include "asterisk/inline_api.h"
178 #include "asterisk/vector.h"
179 
180 /*!
181  \internal
182  \brief An opaque type for managed string fields in structures
183 
184  Don't declare instances of this type directly; use the AST_STRING_FIELD()
185  macro instead.
186 
187  In addition to the string itself, the amount of space allocated for the
188  field is stored in the two bytes immediately preceding it.
189 */
190 typedef const char * ast_string_field;
191 
192 /* the type of storage used to track how many bytes were allocated for a field */
193 
195 
196 /*!
197  \internal
198  \brief A constant empty string used for fields that have no other value
199 */
200 extern const char *__ast_string_field_empty;
201 
202 /*!
203  \internal
204  \brief Structure used to hold a pool of space for string fields
205  \note base is aligned so base+used can stay aligned by incrementing used with
206  aligned numbers only
207 */
209  struct ast_string_field_pool *prev; /*!< pointer to the previous pool, if any */
210  size_t size; /*!< the total size of the pool */
211  size_t used; /*!< the space used in the pool */
212  size_t active; /*!< the amount of space actively in use by fields */
213  char base[0] __attribute__((aligned(__alignof__(ast_string_field_allocation)))); /*!< storage space for the fields */
214 };
215 
216 /*!
217  \internal
218  \brief The definition for the string field vector used for compare and copy
219  \since 13.9.0
220 */
221 AST_VECTOR(ast_string_field_vector, const char **);
222 
223 /*!
224  \internal
225  \brief Structure used to manage the storage for a set of string fields.
226 */
228  ast_string_field last_alloc; /*!< the last field allocated */
229  struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */
230  struct ast_string_field_vector string_fields; /*!< field vector for compare and copy */
231 };
232 
233 /*!
234  \internal
235  \brief Attempt to 'grow' an already allocated field to a larger size
236  \param mgr Pointer to the pool manager structure
237  \param needed Amount of space needed for this field
238  \param ptr Pointer to a field within the structure
239  \return 0 on success, non-zero on failure
240 
241  This function will attempt to increase the amount of space allocated to
242  an existing field to the amount requested; this is only possible if the
243  field was the last field allocated from the current storage pool and
244  the pool has enough space available. If so, the additional space will be
245  allocated to this field and the field's address will not be changed.
246 */
248  struct ast_string_field_pool **pool_head, size_t needed,
249  const ast_string_field *ptr);
250 
251 /*!
252  \internal
253  \brief Allocate space for a field
254  \param mgr Pointer to the pool manager structure
255  \param needed Amount of space needed for this field
256  \param fields Pointer to the first entry of the field array
257  \return NULL on failure, an address for the field on success.
258 
259  This function will allocate the requested amount of space from
260  the field pool. If the requested amount of space is not available,
261  an additional pool will be allocated.
262 */
264  struct ast_string_field_pool **pool_head, size_t needed,
265  const char *file, int lineno, const char *func);
266 
267 /*!
268  \internal
269  \brief Set a field to a complex (built) value
270  \param mgr Pointer to the pool manager structure
271  \param pool_head Pointer to the current pool
272  \param ptr Pointer to a field within the structure
273  \param format printf-style format string
274  \return nothing
275 */
276 void __ast_string_field_ptr_build(const char *file, int lineno, const char *func,
277  struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head,
278  ast_string_field *ptr, const char *format, ...) __attribute__((format(printf, 7, 8)));
279 
280 /*!
281  \internal
282  \brief Set a field to a complex (built) value
283  \param mgr Pointer to the pool manager structure
284  \param pool_head Pointer to the current pool
285  \param ptr Pointer to a field within the structure
286  \param format printf-style format string
287  \param args va_list of the args for the format_string
288  \return nothing
289 */
291  struct ast_string_field_pool **pool_head,
292  ast_string_field *ptr, const char *format, va_list ap,
293  const char *file, int lineno, const char *func) __attribute__((format(printf, 4, 0)));
294 
295 /*!
296  \brief Declare a string field
297  \param name The field name
298 */
299 #define AST_STRING_FIELD(name) const ast_string_field name
300 
301 /*!
302  \brief Declare an extended string field
303  \since 13.9.0
304 
305  \param name The field name
306 */
307 #define AST_STRING_FIELD_EXTENDED(name) AST_STRING_FIELD(name)
308 
310  /*!
311  * Reset all string fields and free all extra pools that may have been created
312  * The allocation or structure can be reused as is.
313  */
315  /*!
316  * Reset all string fields and free all pools.
317  * If the pointer was returned by ast_calloc_with_stringfields, it can NOT be reused
318  * and should be immediately freed. Otherwise, you must call ast_string_field_init
319  * again if you want to reuse it.
320  */
322 };
323 
324 /*!
325  \brief Declare the fields needed in a structure
326  \param field_list The list of fields to declare, using AST_STRING_FIELD() for each one.
327  Internally, string fields are stored as a pointer to the head of the pool,
328  followed by individual string fields, and then a struct ast_string_field_mgr
329  which describes the space allocated.
330  We split the two variables so they can be used as markers around the
331  field_list, and this allows us to determine how many entries are in
332  the field, and play with them.
333  In particular, for writing to the fields, we rely on __field_mgr_pool to be
334  a non-const pointer, so we know it has the same size as ast_string_field,
335  and we can use it to locate the fields.
336 */
337 #define AST_DECLARE_STRING_FIELDS(field_list) \
338  struct ast_string_field_pool *__field_mgr_pool; \
339  field_list \
340  struct ast_string_field_mgr __field_mgr
341 
342 /*!
343  \brief Initialize a field pool and fields
344  \param x Pointer to a structure containing fields
345  \param size Amount of storage to allocate.
346  Use AST_STRINGFIELD_RESET to reset fields to the default value,
347  and release all but the most recent pool.
348  AST_STRINGFIELD_DESTROY (used internally) means free all pools which is
349  equivalent to calling ast_string_field_free_memory.
350 
351  \return 0 on success, non-zero on failure
352 */
353 #define ast_string_field_init(x, size) \
354 ({ \
355  int __res__ = -1; \
356  if (((void *)(x)) != NULL) { \
357  __res__ = __ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, size, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
358  } \
359  __res__ ; \
360 })
361 
362 /*!
363  * \brief free all memory - to be called before destroying the object
364  *
365  * \param x
366  *
367  */
368 #define ast_string_field_free_memory(x) \
369 ({ \
370  int __res__ = -1; \
371  if (((void *)(x)) != NULL) { \
372  __res__ = __ast_string_field_free_memory(&(x)->__field_mgr, &(x)->__field_mgr_pool, \
373  AST_STRINGFIELD_DESTROY, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
374  } \
375  __res__; \
376 })
377 
379  struct ast_string_field_pool **pool_head, enum ast_stringfield_cleanup_type cleanup_type,
380  const char *file, int lineno, const char *func);
381 
382 /*!
383  * \brief Initialize an extended string field
384  * \since 13.9.0
385  *
386  * \param x Pointer to a structure containing the field
387  * \param field The extended field to initialize
388  * \retval zero on success
389  * \retval non-zero on error
390  *
391  * \note
392  * This macro must be called on ALL fields defined with AST_STRING_FIELD_EXTENDED after
393  * ast_string_field_init has been called.
394  */
395 #define ast_string_field_init_extended(x, field) \
396 ({ \
397  int __res__ = -1; \
398  if (((void *)(x)) != NULL) { \
399  ast_string_field *non_const = (ast_string_field *)&(x)->field; \
400  *non_const = __ast_string_field_empty; \
401  __res__ = AST_VECTOR_APPEND(&(x)->__field_mgr.string_fields, non_const); \
402  } \
403  __res__; \
404 })
405 
406 /*!
407  * \internal
408  * \brief internal version of ast_string_field_init
409  */
410 int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head,
411  int needed, const char *file, int lineno, const char *func);
412 
413 /*!
414  * \brief Allocate a structure with embedded stringfields in a single allocation
415  * \param n Current imlementation only allows 1 structure to be allocated
416  * \param type The type of structure to allocate
417  * \param size The number of bytes of space (minimum) to allocate for stringfields to use
418  * in each structure
419  *
420  * This function will allocate memory for one or more structures that use stringfields, and
421  * also allocate space for the stringfields and initialize the stringfield management
422  * structure embedded in the outer structure.
423  *
424  * \since 1.8
425  */
426 #define ast_calloc_with_stringfields(n, type, size) \
427  __ast_calloc_with_stringfields(n, sizeof(type), offsetof(type, __field_mgr), \
428  offsetof(type, __field_mgr_pool), size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
429 
430 /*!
431  * \internal
432  * \brief internal version of ast_calloc_with_stringfields
433  */
434 void *__ast_calloc_with_stringfields(unsigned int num_structs,
435  size_t struct_size, size_t field_mgr_offset, size_t field_mgr_pool_offset, size_t pool_size,
436  const char *file, int lineno, const char *func);
437 
438 /*!
439  \internal
440  \brief Release a field's allocation from a pool
441  \param pool_head Pointer to the current pool
442  \param ptr Field to be released
443  \return nothing
444 
445  This function will search the pool list to find the pool that contains
446  the allocation for the specified field, then remove the field's allocation
447  from that pool's 'active' count. If the pool's active count reaches zero,
448  and it is not the current pool, then it will be freed.
449  */
451  const ast_string_field ptr);
452 
453 /*!
454  \brief Macro to provide access to the allocation field that lives immediately in front of a string field
455  \param x Pointer to the string field
456 
457  Note that x must be a pointer to a byte-sized type -- normally (char *) -- or this calculation
458  would break horribly
459 */
460 #define AST_STRING_FIELD_ALLOCATION(x) *((ast_string_field_allocation *) (x - __alignof__(ast_string_field_allocation)))
461 
462 /*!
463  \brief Set a field to a simple string value
464  \param x Pointer to a structure containing fields
465  \param ptr Pointer to a field within the structure
466  \param data String value to be copied into the field
467  \retval zero on success
468  \retval non-zero on error
469 */
470 #define ast_string_field_ptr_set(x, ptr, data) \
471 ({ \
472  int __res__ = -1; \
473  if (((void *)(x)) != NULL) { \
474  __res__ = ast_string_field_ptr_set_by_fields((x)->__field_mgr_pool, (x)->__field_mgr, ptr, data); \
475  } \
476  __res__; \
477 })
478 
479 #define __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, file, lineno, func) \
480 ({ \
481  int __res__ = 0; \
482  const char *__d__ = (data); \
483  size_t __dlen__ = (__d__) ? strlen(__d__) + 1 : 1; \
484  ast_string_field *__p__ = (ast_string_field *) (ptr); \
485  ast_string_field target = *__p__; \
486  if (__dlen__ == 1) { \
487  __ast_string_field_release_active(field_mgr_pool, *__p__); \
488  *__p__ = __ast_string_field_empty; \
489  } else if ((__dlen__ <= AST_STRING_FIELD_ALLOCATION(*__p__)) || \
490  (!__ast_string_field_ptr_grow(&field_mgr, &field_mgr_pool, __dlen__, __p__)) || \
491  (target = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__, file, lineno, func))) { \
492  if (target != *__p__) { \
493  __ast_string_field_release_active(field_mgr_pool, *__p__); \
494  *__p__ = target; \
495  } \
496  memcpy(* (void **) __p__, __d__, __dlen__); \
497  } else { \
498  __res__ = -1; \
499  } \
500  __res__; \
501 })
502 
503 #define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) \
504  __ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
505 
506 /*!
507  \brief Set a field to a simple string value
508  \param x Pointer to a structure containing fields
509  \param field Name of the field to set
510  \param data String value to be copied into the field
511  \retval zero on success
512  \retval non-zero on error
513 */
514 #define ast_string_field_set(x, field, data) \
515 ({ \
516  int __res__ = -1; \
517  if (((void *)(x)) != NULL) { \
518  __res__ = ast_string_field_ptr_set(x, &(x)->field, data); \
519  } \
520  __res__; \
521 })
522 
523 /*!
524  \brief Set a field to a complex (built) value
525  \param x Pointer to a structure containing fields
526  \param ptr Pointer to a field within the structure
527  \param fmt printf-style format string
528  \param args Arguments for format string
529  \return nothing
530 */
531 #define ast_string_field_ptr_build(x, ptr, fmt, args...) \
532 ({ \
533  int __res__ = -1; \
534  if (((void *)(x)) != NULL) { \
535  __ast_string_field_ptr_build(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
536  &(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args); \
537  __res__ = 0; \
538  } \
539  __res__; \
540 })
541 
542 /*!
543  \brief Set a field to a complex (built) value
544  \param x Pointer to a structure containing fields
545  \param field Name of the field to set
546  \param fmt printf-style format string
547  \param args Arguments for format string
548  \return nothing
549 */
550 #define ast_string_field_build(x, field, fmt, args...) \
551 ({ \
552  int __res__ = -1; \
553  if (((void *)(x)) != NULL) { \
554  __ast_string_field_ptr_build(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
555  &(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args); \
556  __res__ = 0; \
557  } \
558  __res__; \
559 })
560 
561 /*!
562  \brief Set a field to a complex (built) value with prebuilt va_lists.
563  \param x Pointer to a structure containing fields
564  \param ptr Pointer to a field within the structure
565  \param fmt printf-style format string
566  \param args Arguments for format string in va_list format
567  \return nothing
568 */
569 #define ast_string_field_ptr_build_va(x, ptr, fmt, args) \
570 ({ \
571  int __res__ = -1; \
572  if (((void *)(x)) != NULL) { \
573  __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) ptr, fmt, args, \
574  __FILE__, __LINE__, __PRETTY_FUNCTION__); \
575  __res__ = 0; \
576  } \
577  __res__; \
578 })
579 
580 /*!
581  \brief Set a field to a complex (built) value
582  \param x Pointer to a structure containing fields
583  \param field Name of the field to set
584  \param fmt printf-style format string
585  \param args Arguments for format string in va_list format
586  \return nothing
587 */
588 #define ast_string_field_build_va(x, field, fmt, args) \
589 ({ \
590  int __res__ = -1; \
591  if (((void *)(x)) != NULL) { \
592  __ast_string_field_ptr_build_va(&(x)->__field_mgr, &(x)->__field_mgr_pool, (ast_string_field *) &(x)->field, fmt, args, \
593  __FILE__, __LINE__, __PRETTY_FUNCTION__); \
594  __res__ = 0; \
595  } \
596  __res__; \
597 })
598 
599 /*!
600  \brief Compare the string fields in two instances of the same structure
601  \since 12
602  \param instance1 The first instance of the structure to be compared
603  \param instance2 The second instance of the structure to be compared
604  \retval zero if all string fields are equal (does not compare non-string field data)
605  \retval non-zero if the values of the string fields differ
606 */
607 #define ast_string_fields_cmp(instance1, instance2) \
608 ({ \
609  int __res__ = -1; \
610  if (((void *)(instance1)) != NULL && ((void *)(instance2)) != NULL) { \
611  __res__ = __ast_string_fields_cmp(&(instance1)->__field_mgr.string_fields, \
612  &(instance2)->__field_mgr.string_fields); \
613  } \
614  __res__; \
615 })
616 
617 int __ast_string_fields_cmp(struct ast_string_field_vector *left, struct ast_string_field_vector *right);
618 
619 /*!
620  \brief Copy all string fields from one instance to another of the same structure
621  \since 12
622  \param copy The instance of the structure to be copied into
623  \param orig The instance of the structure to be copied from
624  \retval zero on success
625  \retval non-zero on error
626 */
627 #define ast_string_fields_copy(copy, orig) \
628 ({ \
629  int __res__ = -1; \
630  if (((void *)(copy)) != NULL && ((void *)(orig)) != NULL) { \
631  __res__ = __ast_string_fields_copy(((copy)->__field_mgr_pool), \
632  (struct ast_string_field_mgr *)&((copy)->__field_mgr), \
633  (struct ast_string_field_mgr *)&((orig)->__field_mgr), \
634  __FILE__, __LINE__, __PRETTY_FUNCTION__); \
635  } \
636  __res__; \
637 })
638 
639 int __ast_string_fields_copy(struct ast_string_field_pool *copy_pool,
640  struct ast_string_field_mgr *copy_mgr, struct ast_string_field_mgr *orig_mgr,
641  const char *file, int lineno, const char *func);
642 
643 #endif /* _ASTERISK_STRINGFIELDS_H */
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: stringfields.c:103
uint16_t ast_string_field_allocation
Definition: stringfields.h:194
AST_VECTOR(ast_string_field_vector, const char **)
struct ast_string_field_pool * embedded_pool
Definition: stringfields.h:229
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: stringfields.c:240
int __ast_string_fields_cmp(struct ast_string_field_vector *left, struct ast_string_field_vector *right)
Definition: stringfields.c:424
const char * __ast_string_field_empty
Definition: stringfields.c:43
const char * ast_string_field
Definition: stringfields.h:190
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: stringfields.c:441
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: stringfields.c:369
Inlinable API function macro.
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: stringfields.c:286
void __ast_string_field_release_active(struct ast_string_field_pool *pool_head, const ast_string_field ptr)
Definition: stringfields.c:261
Vector container support.
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: stringfields.c:202
ast_stringfield_cleanup_type
Definition: stringfields.h:309
struct ast_string_field_pool * prev
Definition: stringfields.h:209
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: stringfields.c:171
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: stringfields.c:380
static snd_pcm_format_t format
Definition: chan_alsa.c:102
ast_string_field last_alloc
Definition: stringfields.h:228