diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-07-23 21:05:22 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-07-23 21:05:22 +0000 |
commit | ee55d65fa407d6fa4ccda5cc85c5b0ffdcadbc95 (patch) | |
tree | 688fd1caf2ddbbb10dc82ff6100c165cc426979c | |
parent | 8ec1a1b17cbd659efff717d65267cd0c055d19f9 (diff) |
revert an optimization that broke ABI... thanks russell!
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@133237 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | include/asterisk/stringfields.h | 23 | ||||
-rw-r--r-- | main/utils.c | 26 |
2 files changed, 2 insertions, 47 deletions
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h index 3a99cf5dc..d8d257f95 100644 --- a/include/asterisk/stringfields.h +++ b/include/asterisk/stringfields.h @@ -123,7 +123,6 @@ struct ast_string_field_mgr { size_t size; /*!< the total size of the current pool */ size_t space; /*!< the space available in the current pool */ size_t used; /*!< the space used in the current pool */ - ast_string_field last_alloc; /*!< the last field allocated */ }; /*! @@ -140,24 +139,6 @@ int __ast_string_field_init(struct ast_string_field_mgr *mgr, size_t size, /*! \internal - \brief Attempt to 'grow' an already allocated field to a larger size - \param mgr Pointer to the pool manager structure - \param needed Amount of space needed for this field - \param fields Pointer to the first entry of the field array - \param index Index position of the field within the structure - \return 0 on success, non-zero on failure - - This function will attempt to increase the amount of space allocated to - an existing field to the amount requested; this is only possible if the - field was the last field allocated from the current storage pool and - the pool has enough space available. If so, the additional space will be - allocated to this field and the field's address will not be changed. -*/ -int __ast_string_field_index_grow(struct ast_string_field_mgr *mgr, size_t needed, - ast_string_field *fields, int index); - -/*! - \internal \brief Allocate space for a field \param mgr Pointer to the pool manager structure \param needed Amount of space needed for this field @@ -258,7 +239,7 @@ void __ast_string_field_index_build_va(struct ast_string_field_mgr *mgr, if ( __dlen__ == 1 ) {\ (x)->__begin_field[index] = __ast_string_field_empty; \ } else { \ - if (!__ast_string_field_index_grow(&(x)->__field_mgr, __dlen__, &(x)->__begin_field[0], index)) { \ + if ((__zz__[0] != 0) && (__dlen__ <= (strlen(__zz__) + 1))) { \ memcpy(__zz__, data, __dlen__); \ } else { \ if (((x)->__begin_field[index] = __ast_string_field_alloc_space(&(x)->__field_mgr, __dlen__, &(x)->__begin_field[0], ast_string_field_count(x)))) \ @@ -273,7 +254,7 @@ void __ast_string_field_index_build_va(struct ast_string_field_mgr *mgr, if ( __dlen__ == 1 ) {\ (x)->__begin_field[index] = __ast_string_field_empty; \ } else { \ - if (!__ast_string_field_index_grow(&(x)->__field_mgr, __dlen__, &(x)->__begin_field[0], index)) { \ + if ((__zz__[0] != 0) && (__dlen__ <= strlen(__zz__) + 1)) { \ ast_verbose("%s: ======replacing '%s' with '%s'\n", logstr, __zz__, data); \ memcpy(__zz__, data, __dlen__); \ } else { \ diff --git a/main/utils.c b/main/utils.c index 8906eff11..9749949e1 100644 --- a/main/utils.c +++ b/main/utils.c @@ -1223,7 +1223,6 @@ static int add_string_pool(struct ast_string_field_mgr *mgr, size_t size) mgr->size = size; mgr->space = size; mgr->used = 0; - mgr->last_alloc = NULL; return 0; } @@ -1260,33 +1259,9 @@ ast_string_field __ast_string_field_alloc_space(struct ast_string_field_mgr *mgr result = mgr->pool->base + mgr->used; mgr->used += needed; mgr->space -= needed; - mgr->last_alloc = result; return result; } -int __ast_string_field_index_grow(struct ast_string_field_mgr *mgr, size_t needed, - ast_string_field *fields, int index) -{ - int grow = needed - (strlen(fields[index]) + 1); - - if (grow <= 0) { - return 0; - } - - if (fields[index] != mgr->last_alloc) { - return 1; - } - - if (mgr->space < grow) { - return 1; - } - - mgr->space -= grow; - mgr->used += grow; - - return 0; -} - void __ast_string_field_index_build_va(struct ast_string_field_mgr *mgr, ast_string_field *fields, int num_fields, int index, const char *format, va_list ap1, va_list ap2) @@ -1310,7 +1285,6 @@ void __ast_string_field_index_build_va(struct ast_string_field_mgr *mgr, } fields[index] = mgr->pool->base + mgr->used; - mgr->last_alloc = fields[index]; mgr->used += needed; mgr->space -= needed; } |