summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@sernet.de>2008-09-09 14:34:28 +0200
committerVolker Lendecke <vl@samba.org>2008-09-09 17:37:34 +0200
commitce47a2b2e3b76edb77673efeb14c4dd0c8cd7aa5 (patch)
tree81203dd5c4cea5f5669d188abdb96d4f594d93c5 /source3/lib
parent6061b3fa6464c43f0f78a84d75a811ee8fb6ba92 (diff)
downloadsamba-ce47a2b2e3b76edb77673efeb14c4dd0c8cd7aa5.tar.gz
samba-ce47a2b2e3b76edb77673efeb14c4dd0c8cd7aa5.tar.bz2
samba-ce47a2b2e3b76edb77673efeb14c4dd0c8cd7aa5.zip
Add a utility function to append a DATA_BLOB to a talloc object
(This used to be commit d8259cbe666d96cc468203a64fb208c02a64849f)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 201d87aeb5..ec43ea7037 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2990,6 +2990,32 @@ void *talloc_check_name_abort(const void *ptr, const char *name)
return NULL;
}
+/**********************************************************************
+ Append a DATA_BLOB to a talloc'ed object
+***********************************************************************/
+
+void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob)
+{
+ size_t old_size = 0;
+ char *result;
+
+ if (blob.length == 0) {
+ return buf;
+ }
+
+ if (buf != NULL) {
+ old_size = talloc_get_size(buf);
+ }
+
+ result = (char *)TALLOC_REALLOC(mem_ctx, buf, old_size + blob.length);
+ if (result == NULL) {
+ return NULL;
+ }
+
+ memcpy(result + old_size, blob.data, blob.length);
+ return result;
+}
+
uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options)
{
switch (share_access & ~FILE_SHARE_DELETE) {