summaryrefslogtreecommitdiff
path: root/main/hashtab.c
AgeCommit message (Collapse)Author
2018-03-01core: Remove ABI effects of MALLOC_DEBUG.Richard Mudgett
This allows asterisk to be compiled with MALLOC_DEBUG to load modules built without MALLOC_DEBUG. Now pre-compiled third-party modules will still work regardless of MALLOC_DEBUG being enabled or not. Change-Id: Ic07ad80b2c2df894db984cf27b16a69383ce0e10
2017-10-23hashtab: Use ast_free.Corey Farrell
A few places in hashtab use free instead of ast_free, remove declaration of ASTMM_LIBC from hashtab.c as it's no longer needed. Change-Id: I2ff089bad71640c03c3ce97f1b00fc962ef79427
2016-10-27Remove ASTERISK_REGISTER_FILE.Corey Farrell
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes all traces of it. Previously exported symbols removed: * __ast_register_file * __ast_unregister_file * ast_complete_source_filename This also removes the mtx_prof static variable that was declared when MTX_PROFILE was enabled. This variable was only used in lock.c so it is now initialized in that file only. ASTERISK-26480 #close Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
2016-08-19Fix checks for allocation debugging.Corey Farrell
MALLOC_DEBUG should not be used to check if debugging is actually enabled, __AST_DEBUG_MALLOC should be used instead. MALLOC_DEBUG only indicates that debugging is requested, __AST_DEBUG_MALLOC indicates it is active. Change-Id: I3ce9cdb6ec91b74ee1302941328462231be1ea53
2015-11-14hashtab: Add NULL check when destroying iterator.Joshua Colp
The hashtab API is pretty NULL tolerant which has resulted in remaining callers not doing much checks themselves. Unfortunately the function to destroy an iterator does not do a NULL check and will result in a crash if passed NULL. This change fixes that. ASTERISK-25552 #close Change-Id: Ic1bf8eec3639e5a440f1c941d3ae3893ac6ed619
2015-05-13MALLOC_DEBUG: Replace WRAP_LIBC_MALLOC with ASTMM_LIBC.Corey Farrell
There are 3 ways that calls directly to standard allocator functions can be dealt with: 1. Block their use, cause them to generate an error. This is the default. 2. Replace them with the Asterisk equivalent function calls. 3. Leave them alone. This change allows one of these 3 options to be selected by any source. The source just needs to define ASTMM_LIBC to ASTMM_BLOCK, ASTMM_REDIRECT, or ASTMM_IGNORE to use option 1, 2 or 3 respectively. Normally ASTMM_BLOCK is the correct option, so it is default when ASTMM_LIBC is not defined. In some cases when building 3rd party code it is desirable to have it use Asterisk functions, without changing the whole source - ASTMM_REDIRECT accomplishes this. When using 3rd party libraries sometimes a static inline function will make use of malloc or free. In these cases it may be unsafe to replace the allocator in the header, as it's possible the memory could be freed by the library using standard allocators. For those cases ASTMM_IGNORE is needed. Change-Id: I8afef4bc7f3b93914263ae27d3a5858b69663fc7
2015-04-13git migration: Refactor the ASTERISK_FILE_VERSION macroMatt Jordan
Git does not support the ability to replace a token with a version string during check-in. While it does have support for replacing a token on clone, this is somewhat sub-optimal: the token is replaced with the object hash, which is not particularly easy for human consumption. What's more, in practice, the source file version was often not terribly useful. Generally, when triaging bugs, the overall version of Asterisk is far more useful than an individual SVN version of a file. As a result, this patch removes Asterisk's support for showing source file versions. Specifically, it does the following: * Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and remove passing the version in with the macro. Other facilities than 'core show file version' make use of the file names, such as setting a debug level only on a specific file. As such, the act of registering source files with the Asterisk core still has use. The macro rename now reflects the new macro purpose. * main/asterisk: - Refactor the file_version structure to reflect that it no longer tracks a version field. - Remove the "core show file version" CLI command. Without the file version, it is no longer useful. - Remove the ast_file_version_find function. The file version is no longer tracked. - Rename ast_register_file_version/ast_unregister_file_version to ast_register_file/ast_unregister_file, respectively. * main/manager: Remove value from the Version key of the ModuleCheck Action. The actual key itself has not been removed, as doing so would absolutely constitute a backwards incompatible change. However, since the file version is no longer tracked, there is no need to attempt to include it in the Version key. * UPGRADE: Add notes for: - Modification to the ModuleCheck AMI Action - Removal of the "core show file version" CLI command Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-03-27Improved and portable ast_log recursion avoidanceCorey Farrell
This introduces a new logger routine ast_log_safe. This routine should be used for all error messages in code that can be run as a result of ast_log. ast_log_safe does nothing if run recursively. All error logging in astobj2.c, strings.c and utils.h have been switched to ast_log_safe. This required adding support for raw threadstorage. This provides direct access to the void* pointer in threadstorage. In ast_log_safe, NULL is used to signify that this thread is not already running ast_log_safe, (void*)1 when it is already running. This was done since it's critical that ast_log_safe do nothing that could log during recursion checking. ASTERISK-24155 #close Reported by: Timo Teräs Review: https://reviewboard.asterisk.org/r/4502/ ........ Merged revisions 433522 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 433523 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433524 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-26core: Don't allow free to mean ast_free (and malloc, etc..).Walter Doekes
This gets rid of most old libc free/malloc/realloc and replaces them with ast_free and friends. When compiling with MALLOC_DEBUG you'll notice it when you're mistakenly using one of the libc variants. For the legacy cases you can define WRAP_LIBC_MALLOC before including asterisk.h. Even better would be if the errors were also enabled when compiling without MALLOC_DEBUG, but that's a slightly more invasive header file change. Those compiling addons/format_mp3 will need to rerun ./contrib/scripts/get_mp3_source.sh. ASTERISK-24348 #related Review: https://reviewboard.asterisk.org/r/4015/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423978 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-16Fix utilities compilation/linking.Richard Mudgett
The horrid structure of the source in the utils directory strikes again. Moved the _ast_mem_backtrace_buffer[] definition from the logical location in utils.c to hashtab.c so the aelparse and conf2ael utilities can link. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-06-15Multiple revisions 369001-369002Kevin P. Fleming
........ r369001 | kpfleming | 2012-06-15 10:56:08 -0500 (Fri, 15 Jun 2012) | 11 lines Add support-level indications to many more source files. Since we now have tools that scan through the source tree looking for files with specific support levels, we need to ensure that every file that is a component of a 'core' or 'extended' module (or the main Asterisk binary) is explicitly marked with its support level. This patch adds support-level indications to many more source files in tree, but avoids adding them to third-party libraries that are included in the tree and to source files that don't end up involved in Asterisk itself. ........ r369002 | kpfleming | 2012-06-15 10:57:14 -0500 (Fri, 15 Jun 2012) | 3 lines Add a script to enable finding source files without support-levels defined. ........ Merged revisions 369001-369002 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 369005 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369013 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-11Add MALLOC_DEBUG to various utility APIs, so that memory leaks can be ↵Tilghman Lesher
tracked back to their source. (related to issue #14636) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@181028 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-21Trailing whitespace, minor coding guideline fixes, and start beefing up theSean Bright
hashtab documentation a bit. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@177884 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-10-14Add additional memory debugging to several core APIs, and fix several memoryTilghman Lesher
leaks found with these changes. (Closes issue #13505, closes issue #13543) Reported by: mav3rick, triccyx Patches: 20081001__bug13505.diff.txt uploaded by Corydon76 (license 14) Tested by: mav3rick, triccyx git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@149199 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-18Fix magic Revision keywords in hashtab.c and change cdr_radius.c to use Brett Bryant
the same keyword as the other files (patch by eliel). (closes issue #13104) Reported by: eliel Patches: revision.patch uploaded by eliel (license 64) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@132050 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-04Make it so you don't have to cast away const in a couple placesRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105594 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-04remove unnecessary castsRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105593 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-12-03A small fix from snuffySteve Murphy
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@90746 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-26closes issue #11356; Many thanks to snuffy for his code review and changes ↵Steve Murphy
to cut down duplication. I tested this against hashtest, and it passes. I reviewed the changes, and they look reasonable. I had to remove a few const decls to make things compile on my workstation, git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89591 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-21remove a bunch of useless #include "options.h"Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-21closes issue #11265; Thanks to snuffy for his work on neatening up the code ↵Steve Murphy
and removing duplicated code. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89478 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-19another bunch of include removals (errno.h and asterisk/logger.h)Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89425 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-14Fix up various coding guidelines issues ...Russell Bryant
- handle memory allocation failures - add an ast_ prefix to a publicly exported function - put curly braces in the right places - add a bunch of spaces where they should be be used git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-12Thanks to snuff-work, who brought up that these fixes might need to be made.Steve Murphy
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89196 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-09This is the perhaps the biggest, boldest, most daring change I've ever ↵Steve Murphy
committed to trunk. Forgive me in advance any disruption this may cause, and please, report any problems via the bugtracker. The upside is that this can speed up large dialplans by 20 times (or more). Context, extension, and priority matching are all fairly constant-time searches. I introduce here my hashtables (hashtabs), and a regression for them. I would have used the ast_obj2 tables, but mine are resizeable, and don't need the object destruction capability. The hashtab stuff is well tested and stable. I introduce a data structure, a trie, for extension pattern matching, in which knowledge of all patterns is accumulated, and all matches can be found via a single traversal of the tree. This is per-context. The trie is formed on the first lookup attempt, and stored in the context for future lookups. Destruction routines are in place for hashtabs and the pattern match trie. You can see the contents of the pattern match trie by using the 'dialplan show' cli command when 'core set debug' has been done to put it in debug mode. The pattern tree traversal only traverses those parts of the tree that are interesting. It uses a scoreboard sort of approach to find the best match. The speed of the traversal is more a function of the length of the pattern than the number of patterns in the tree. The tree also contains the CID matching patterns. See the source code comments for details on how everything works. I believe the approach general enough that any issues that might come up involving fine points in the pattern matching algorithm, can be solved by just tweaking things. We shall see. The current pattern matcher is fairly involved, and replicating every nuance of it is difficult. If you find and report problems, I will try to resolve than as quickly as I can. The trie and hashtabs are added to the existing context and exten structs, and none of the old machinery has been removed for the sake of the multitude of functions that use them. In the future, we can (maybe) weed out the linked lists and save some space. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89129 65c4cc65-6c06-0410-ace0-fbb531ad65f3