summaryrefslogtreecommitdiff
path: root/include/asterisk/stringfields.h
AgeCommit message (Collapse)Author
2014-11-19stringfields: Fix bug in ast_string_fields_copy.Corey Farrell
ast_string_fields_copy relies on the fact that __ast_string_field_release_active never previously zeroed pool->used, so keeping the existing pointer was "ok". Now that existing pools can be reset to 'empty', it is important to set each field to __ast_string_field_empty after releasing the memory. ASTERISK-24535 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4186/ ........ Merged revisions 428272 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 428273 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@428274 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-11-06Fix unintential memory retention in stringfields.Corey Farrell
* Fix missing / unreachable calls to __ast_string_field_release_active. * Reset pool->used to zero when the current pool->active reaches zero. ASTERISK-24307 #close Reported by: Etienne Lessard Tested by: ibercom, Etienne Lessard Review: https://reviewboard.asterisk.org/r/4114/ ........ Merged revisions 427380 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 427381 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 427382 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 427384 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@427388 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-02-07Add aggregate operations for stuctures with string fieldsKinsey Moore
Add struct-level comparison and copying of string fields to reduce the complexity of whole-struct comparison and copying when using string fields. The new macros do not take into account non-stringfield data. Review: https://reviewboard.asterisk.org/r/2308/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381017 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-01Add new config-parsing frameworkTerry Wilson
This framework adds a way to register the various options in a config file with Asterisk and to handle loading and reloading of that config in a consistent and atomic manner. Review: https://reviewboard.asterisk.org/r/1873/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368181 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-02-29Update stringfield documentation for removed second va_list in favor of va_copy.Walter Doekes
In r320946, the second va_list that was passed to ast_string_field_build_va and friends, was removed. This patch updates the documentation to reflect that. ........ Merged revisions 357620 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@357621 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-11Use __alignof__ instead of sizeof for stringfield length storage.Walter Doekes
Kevin P Fleming suggested that r343157 should use __alignof__ instead of sizeof. For most systems this won't be an issue, but better fix it now while it's still fresh. Review: https://reviewboard.asterisk.org/r/1573 ........ Merged revisions 344843 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 344845 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@344846 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-11-02Ensure that string field lengths are properly alignedWalter Doekes
Integers should always be aligned. For some platforms (ARM, SPARC) this is more important than for others. This changeset ensures that the string field string lengths are aligned on *all* platforms, not just on the SPARC for which there was a workaround. It also fixes that the length integer can be resized to 32 bits without problems if needed. (closes issue ASTERISK-17310) Reported by: radael, S Adrian Reviewed by: Tzafrir Cohen, Terry Wilson Tested by: S Adrian Review: https://reviewboard.asterisk.org/r/1549 ........ Merged revisions 343157 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 343158 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@343163 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-05-26Use va_copy for stringfieldsTerry Wilson
The ast_string_field_build_va functions were written to take to separate va_lists to work around FreeBSD 4 not having va_copy defined. In the end, we don't support anything using gcc < 3 anyway because we use va_copy all over the place anyway. This patch just simplifies things by removing the second va_list function arguments in favor of va_copy. Review: https://reviewboard.asterisk.org/r/1233/ --This line, and those below, will be ignored-- M include/asterisk/stringfields.h M main/utils.c M main/channel.c git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@320946 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-12-21Change all refererences to 1.6.3 to be 1.8, since that will be the next ↵Kevin P. Fleming
feature release git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@235904 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-05Add a more efficient way of allocating structures that use stringfieldsKevin P. Fleming
This commit adds an API call that can be used to allocate a structure along with this stringfield storage in a single allocation. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192362 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-05Correct some flaws in the memory accounting code for stringfields and ao2 ↵Kevin P. Fleming
objects Under some conditions, the memory allocation for stringfields and ao2 objects would not have supplied valid file/function names for MALLOC_DEBUG tracking, so this commit corrects that. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192357 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-05Ensure that string pools allocated to hold stringfields are properly ↵Kevin P. Fleming
accounted in MALLOC_DEBUG mode This commit modifies the stringfield pool allocator to remember the 'owner' of the stringfield manager the pool is being allocated for, and ensures that pools allocated in the future when fields are populated are owned by that file/function. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@192279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-01Fix dev-mode build on my box.Russell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@185741 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-31Optimizations to the stringfields APIKevin P. Fleming
This patch provides a number of optimizations to the stringfields API, focused around saving (not wasting) memory whenever possible. Thanks to Mark Michelson for inspiring this work and coming up with the first two optimizations that are represented here: Changes: - Cleanup of some code, fix incorrect doxygen comments - When a field is emptied or replaced with a new allocation, decrease the amount of 'active' space in the pool it was held in; if that pool reaches zero active space, and is not the current pool, then free it as it is no longer in use - When allocating a pool, try to allocate a size that will fit in a 'standard' malloc() allocation without wasting space - When allocating space for a field, store the amount of space in the two bytes immediately preceding the field; this eliminates the need to call strlen() on the field when overwriting it, and more importantly it 'remembers' the amount of space the field has available, even if a shorter string has been stored in it since it was allocated - Don't automatically double the size of each successive pool allocated; it's wasteful http://reviewboard.digium.com/r/165/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@185581 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-16Merged revisions 176216 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r176216 | kpfleming | 2009-02-16 15:10:38 -0600 (Mon, 16 Feb 2009) | 3 lines fix a flaw in the ast_string_field_build() family of API calls; these functions made no attempt to reuse the space already allocated to a field, so every time the field was written it would allocate new space, leading to what appeared to be a memory leak. ........ r176254 | kpfleming | 2009-02-16 15:41:46 -0600 (Mon, 16 Feb 2009) | 3 lines correct a logic error in the last stringfields commit... don't mark additional space as allocated if the string was built using already-allocated space ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@176255 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-09it does help if the compiler attribute syntax is correctKevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@162488 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-02Merged revisions 160207 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r160207 | tilghman | 2008-12-01 18:25:16 -0600 (Mon, 01 Dec 2008) | 3 lines Ensure that Asterisk builds with --enable-dev-mode, even on the latest gcc and glibc. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@160208 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-29incorporates r159808 from branches/1.4:Kevin P. Fleming
------------------------------------------------------------------------ r159808 | kpfleming | 2008-11-29 10:58:29 -0600 (Sat, 29 Nov 2008) | 7 lines update dev-mode compiler flags to match the ones used by default on Ubuntu Intrepid, so all developers will see the same warnings and errors since this branch already had some printf format attributes, enable checking for them and tag functions that didn't have them format attributes in a consistent way ------------------------------------------------------------------------ in addition: move some format attributes from main/utils.c to the header files they belong in, and fix up references to the relevant functions based on new compiler warnings git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@159818 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-23Merged revisions 132872 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r132872 | kpfleming | 2008-07-23 06:52:18 -0500 (Wed, 23 Jul 2008) | 2 lines minor optimization for stringfields: when a field is being set to a larger value than it currently contains and it happens to be the most recent field allocated from the currentl pool, it is possible to 'grow' it without having to waste the space it is currently using (or potentially even allocate a new pool) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@132964 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16remove redundant #include "asterisk/compat.h",Luigi Rizzo
but make sure that asterisk/compiler.h is included everywhere git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89336 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16Start untangling header inclusion in a way that does not affectLuigi Rizzo
build times - tested, there is no measureable difference before and after this commit. In this change: use asterisk/compat.h to include a small set of system headers: inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h, stdlib.h, alloca.h, stdio.h Where available, the inclusion is conditional on HAVE_FOO_H as determined by autoconf. Normally, source files should not include any of the above system headers, and instead use either "asterisk.h" or "asterisk/compat.h" which does it better. For the time being I have left alone second-level directories (main/db1-ast, etc.). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-15If we're going to be passing a negative value for the size of a stringfield,Tilghman Lesher
in order to indicate something, then using an UNSIGNED parameter is bad, mmmmmkay? git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89312 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-12Doxygen fixes.Jason Parker
Also fix a common typo I kept seeing (arguement) in various files. Closes issue #11222, patch by snuffy (with arguement > argument by me). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89202 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-04Simplify the implementation and the API for stringfields;Luigi Rizzo
details and examples are in include/asterisk/stringfields.h. Not applicable to older branches except for 1.4 which will receive a fix for the routines that free memory pools. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@88454 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-09-05Doxygen cleanups/fixes.Jason Parker
Closes issue #10654, patch by snuffy git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81560 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-07Fix a bunch of doxygen errors and document more thingsRussell Bryant
(issue #9842, snuffy) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@68339 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-04Fix some compiler warnings in C++ modules.Russell Bryant
(issue #9866, reported by osk, patch by Corydon76) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67017 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-07A fair number of changes for the sake of bug 7506Steve Murphy
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47290 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17Merged revisions 45408 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r45408 | kpfleming | 2006-10-17 17:24:10 -0500 (Tue, 17 Oct 2006) | 3 lines optimize the 'quick response' code a bit more... no more malloc() or memset() for each response expand stringfields API a bit to allow reusing the stringfield pool on a structure when needed, and remove some unnecessary code when the structure was being freed ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45409 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-07This commit folds in changes to both stringfields (some enhancements to the ↵Steve Murphy
...field_set() macro, to optimize setting strings to empty, resetting strings to shorter contents, etc.) and to chan_iax2.c, to use stringfields in the user, peer, and pvt structs. Has been running stably on iaxtel, but while iaxtel has a large registration volume, it doesn't seem to have a high call volume. So far, it seems to reduce heap usage by over half. YMMV\! Please report any IAX bugs that might involve stringfields\! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39203 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-09various minor portability fixes (mostly from tholo for OpenBSD)Kevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@33350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-06fix some typos in the stringfields documentationRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@32455 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-06-05fix a typo in the documentation of how to use string fieldsRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@32161 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-02-11eliminate warning on older versions of gccRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9629 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-02-01use string fields for some stuff in ast_channelKevin P. Fleming
const-ify some more APIs remove 'type' field from ast_channel, in favor of the one in the channel's tech structure allow string field module users to specify the 'chunk size' for pool allocations update chan_alsa to be compatible with recent const-ification patches git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@9060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-01-26string field manager improvements:Kevin P. Fleming
use multiple memory blocks, instead of realloc(), ensuring that field pointers will never become invalid or change don't run vs(n)printf twice when doing a field build unless required git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8697 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-01-06ensure that string field 'build' operation only evaluates arguments one timeKevin P. Fleming
fix some minor documentation errors return proper type from string field space allocator git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7841 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-01-04add memory-pool based string field management for structuresKevin P. Fleming
convert chan_sip sip_pvt and sip_registry structures to use string fields add 'const' qualifiers to a few API calls that don't modify their input strings add an asprintf() wrapper to astmm git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7797 65c4cc65-6c06-0410-ace0-fbb531ad65f3