stringfields: Update extended string fields for master only.

In 13, the new ast_string_field_header structure had to be dynamically
allocated and assigned to a pointer in ast_string_field_mgr to preserve ABI
compatability.  In master, it can be converted to being a structure-in-place in
ast_string_field_mgr to eliminate the extra alloc and free calls.

Change-Id: Ia97c5345eec68717a15dc16fe2e6746ff2a926f4
This commit is contained in:
George Joseph
2016-04-13 12:38:01 -06:00
parent fddec0c266
commit caa416d5f3
3 changed files with 28 additions and 62 deletions

View File

@@ -220,23 +220,14 @@ struct ast_string_field_pool {
*/
AST_VECTOR(ast_string_field_vector, const char **);
/*!
\internal
\brief Structure used to hold a pointer to the embedded pool and the field vector
\since 13.9.0
*/
struct ast_string_field_header {
struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */
struct ast_string_field_vector string_fields; /*!< field vector for compare and copy */
};
/*!
\internal
\brief Structure used to manage the storage for a set of string fields.
*/
struct ast_string_field_mgr {
ast_string_field last_alloc; /*!< the last field allocated */
struct ast_string_field_header *header; /*!< pointer to the header */
struct ast_string_field_pool *embedded_pool; /*!< pointer to the embedded pool, if any */
struct ast_string_field_vector string_fields; /*!< field vector for compare and copy */
#if defined(__AST_DEBUG_MALLOC)
const char *owner_file; /*!< filename of owner */
const char *owner_func; /*!< function name of owner */
@@ -407,10 +398,10 @@ int __ast_string_field_free_memory(struct ast_string_field_mgr *mgr,
#define ast_string_field_init_extended(x, field) \
({ \
int __res__ = -1; \
if (((void *)(x)) != NULL && (x)->__field_mgr.header != NULL) { \
if (((void *)(x)) != NULL) { \
ast_string_field *non_const = (ast_string_field *)&(x)->field; \
*non_const = __ast_string_field_empty; \
__res__ = AST_VECTOR_APPEND(&(x)->__field_mgr.header->string_fields, non_const); \
__res__ = AST_VECTOR_APPEND(&(x)->__field_mgr.string_fields, non_const); \
} \
__res__; \
})
@@ -613,8 +604,8 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head,
({ \
int __res__ = -1; \
if (((void *)(instance1)) != NULL && ((void *)(instance2)) != NULL) { \
__res__ = __ast_string_fields_cmp(&(instance1)->__field_mgr.header->string_fields, \
&(instance2)->__field_mgr.header->string_fields); \
__res__ = __ast_string_fields_cmp(&(instance1)->__field_mgr.string_fields, \
&(instance2)->__field_mgr.string_fields); \
} \
__res__; \
})