aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/strings.h
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-04 23:18:36 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-04 23:18:36 +0000
commitcdcfae52305bc229a9e500857904b945ead2aaad (patch)
tree7a611d8d292ad6f75bb7d77e5a3348a76706f30f /include/asterisk/strings.h
parentae60d026a05a6b63a9544d9bc545533a167c00c9 (diff)
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: http://svn.digium.com/svn/asterisk/trunk@49578 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/strings.h')
-rw-r--r--include/asterisk/strings.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index f79e9b2fe..53486d1b0 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -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;