summaryrefslogtreecommitdiff
path: root/source3/rpc_parse/parse_misc.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-27 17:48:44 -0800
committerJeremy Allison <jra@samba.org>2007-11-27 17:48:44 -0800
commitcef494d90366fbff638c72efd5a41a22a834ae20 (patch)
treeec6622b3e49cefaf2a5fb2556222a66b756fb65f /source3/rpc_parse/parse_misc.c
parent6b6655edd90850d09c7711fc3b9fe98271e3e625 (diff)
downloadsamba-cef494d90366fbff638c72efd5a41a22a834ae20.tar.gz
samba-cef494d90366fbff638c72efd5a41a22a834ae20.tar.bz2
samba-cef494d90366fbff638c72efd5a41a22a834ae20.zip
Make init_unistr2_from_unistr take an explicit talloc context.
Make init_unistr() re-use rpcstr_push_talloc(). Jeremy. (This used to be commit 04aecde5cfdb00d5aa32f9675c797266aba83c0f)
Diffstat (limited to 'source3/rpc_parse/parse_misc.c')
-rw-r--r--source3/rpc_parse/parse_misc.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 2e85b59a4b..783c7fb7b3 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -430,16 +430,9 @@ void init_unistr(UNISTR *str, const char *buf)
str->buffer = NULL;
return;
}
-
- len = strlen(buf) + 1;
- if (len) {
- str->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, len);
- if (str->buffer == NULL)
- smb_panic("init_unistr: malloc fail");
-
- rpcstr_push(str->buffer, buf, len*sizeof(uint16), STR_TERMINATE);
- } else {
+ len = rpcstr_push_talloc(talloc_tos(), &str->buffer, buf);
+ if (len == (size_t)-1) {
str->buffer = NULL;
}
}
@@ -870,7 +863,7 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
Inits a UNISTR2 structure from a UNISTR
********************************************************************/
-void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from)
+void init_unistr2_from_unistr(TALLOC_CTX *ctx, UNISTR2 *to, const UNISTR *from)
{
uint32 i;
@@ -898,9 +891,9 @@ void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from)
/* allocate the space and copy the string buffer */
if (i) {
- to->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, i);
+ to->buffer = TALLOC_ZERO_ARRAY(ctx, uint16, i);
if (to->buffer == NULL)
- smb_panic("init_unistr2_from_unistr: malloc fail");
+ smb_panic("init_unistr2_from_unistr: talloc fail");
memcpy(to->buffer, from->buffer, i*sizeof(uint16));
} else {
to->buffer = NULL;