Merged revisions 49553 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r49553 | kpfleming | 2007-01-04 16:51:01 -0600 (Thu, 04 Jan 2007) | 2 lines

add support for tracking thread-local-storage objects that exist via 'threadstorage' CLI commands

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2007-01-04 23:18:36 +00:00
parent 5a140436f3
commit 4764795b37
7 changed files with 302 additions and 13 deletions

View File

@@ -365,6 +365,10 @@ void ast_str_reset(struct ast_str *buf),
AST_INLINE_API(
int ast_str_make_space(struct ast_str **buf, size_t new_len),
{
#if defined(DEBUG_THREADLOCALS)
struct ast_str *old_buf = *buf;
#endif /* defined(DEBUG_THREADLOCALS) */
if (new_len <= (*buf)->len)
return 0; /* success */
if ((*buf)->ts == DS_ALLOCA || (*buf)->ts == DS_STATIC)
@@ -372,8 +376,12 @@ int ast_str_make_space(struct ast_str **buf, size_t new_len),
*buf = (struct ast_str *)ast_realloc(*buf, new_len + sizeof(struct ast_str));
if (*buf == NULL) /* XXX watch out, we leak memory here */
return -1;
if ((*buf)->ts != DS_MALLOC)
if ((*buf)->ts != DS_MALLOC) {
pthread_setspecific((*buf)->ts->key, *buf);
#if defined(DEBUG_THREADLOCALS)
__ast_threadstorage_object_replace(old_buf, *buf, new_len + sizeof(struct ast_str));
#endif /* defined(DEBUG_THREADLOCALS) */
}
(*buf)->len = new_len;
return 0;