Add a utility function to append a DATA_BLOB to a talloc object
authorVolker Lendecke <vl@sernet.de>
Tue, 9 Sep 2008 12:34:28 +0000 (14:34 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 9 Sep 2008 15:37:34 +0000 (17:37 +0200)
(This used to be commit d8259cbe666d96cc468203a64fb208c02a64849f)

source3/include/proto.h
source3/lib/util.c

index e94a2178c0ae3a348a12cca22087e68696c2b3b1..8d033f1837ba3018668011c1d58e93763011a1e2 100644 (file)
@@ -1354,6 +1354,7 @@ bool mask_match_list(const char *string, char **list, int listLen, bool is_case_
 bool unix_wild_match(const char *pattern, const char *string);
 bool name_to_fqdn(fstring fqdn, const char *name);
 void *talloc_check_name_abort(const void *ptr, const char *name);
+void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
 uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options);
 pid_t procid_to_pid(const struct server_id *proc);
 void set_my_vnn(uint32 vnn);
index 201d87aeb5cf51a9eddea8cdd0d914ecc5e0737f..ec43ea7037dc73aa05e0c81447b89906992f9a10 100644 (file)
@@ -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) {