summaryrefslogtreecommitdiffstats
path: root/bstr.h
diff options
context:
space:
mode:
Diffstat (limited to 'bstr.h')
-rw-r--r--bstr.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/bstr.h b/bstr.h
index b3f942535e..99b7eea578 100644
--- a/bstr.h
+++ b/bstr.h
@@ -36,14 +36,18 @@ struct bstr {
// demux_rtp.cpp (live555) C++ compilation workaround
#ifndef __cplusplus
+// If str.start is NULL, return NULL.
static inline char *bstrdup0(void *talloc_ctx, struct bstr str)
{
return talloc_strndup(talloc_ctx, (char *)str.start, str.len);
}
+// Return start = NULL iff that is true for the original.
static inline struct bstr bstrdup(void *talloc_ctx, struct bstr str)
{
- struct bstr r = { talloc_strndup(talloc_ctx, str.start, str.len), str.len };
+ struct bstr r = { NULL, str.len };
+ if (str.start)
+ r.start = talloc_memdup(talloc_ctx, str.start, str.len);
return r;
}