aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/strings.h
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-04 23:38:10 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2007-01-04 23:38:10 +0000
commit5e1bd58600a68709af39f6472720423a53a4d8f7 (patch)
tree6c3a0f9efc2ff2f1e35da442849f64ea8f38e979 /include/asterisk/strings.h
parentc38f3b681ad3dd525a84e6084db4501b33b4c263 (diff)
ensure that the proper file/function/line shows up for dynamic string threadstorage objects
remove pointless casts git-svn-id: http://svn.digium.com/svn/asterisk/trunk@49580 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/strings.h')
-rw-r--r--include/asterisk/strings.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index 53486d1b0..c91ecaec3 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -333,7 +333,7 @@ struct ast_str * attribute_malloc ast_str_create(size_t init_len),
{
struct ast_str *buf;
- buf = (struct ast_str *)ast_calloc(1, sizeof(*buf) + init_len);
+ buf = ast_calloc(1, sizeof(*buf) + init_len);
if (buf == NULL)
return NULL;
@@ -373,7 +373,7 @@ int ast_str_make_space(struct ast_str **buf, size_t new_len),
return 0; /* success */
if ((*buf)->ts == DS_ALLOCA || (*buf)->ts == DS_STATIC)
return -1; /* cannot extend */
- *buf = (struct ast_str *)ast_realloc(*buf, new_len + sizeof(struct ast_str));
+ *buf = 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) {
@@ -431,13 +431,14 @@ int ast_str_make_space(struct ast_str **buf, size_t new_len),
* }
* \endcode
*/
+#if !defined(DEBUG_THREADLOCALS)
AST_INLINE_API(
struct ast_str *ast_str_thread_get(struct ast_threadstorage *ts,
size_t init_len),
{
struct ast_str *buf;
- buf = (struct ast_str *)ast_threadstorage_get(ts, sizeof(*buf) + init_len);
+ buf = ast_threadstorage_get(ts, sizeof(*buf) + init_len);
if (buf == NULL)
return NULL;
@@ -450,6 +451,29 @@ struct ast_str *ast_str_thread_get(struct ast_threadstorage *ts,
return buf;
}
)
+#else /* defined(DEBUG_THREADLOCALS) */
+AST_INLINE_API(
+struct ast_str *__ast_str_thread_get(struct ast_threadstorage *ts,
+ size_t init_len, const char *file, const char *function, unsigned int line),
+{
+ struct ast_str *buf;
+
+ buf = __ast_threadstorage_get(ts, sizeof(*buf) + init_len, file, function, line);
+ if (buf == NULL)
+ return NULL;
+
+ if (!buf->len) {
+ buf->len = init_len;
+ buf->used = 0;
+ buf->ts = ts;
+ }
+
+ return buf;
+}
+)
+
+#define ast_str_thread_get(ts, init_len) __ast_str_thread_get(ts, init_len, __FILE__, __PRETTY_FUNCTION__, __LINE__)
+#endif /* defined(DEBUG_THREADLOCALS) */
/*!
* \brief Error codes from __ast_str_helper()