r4591: - converted the other _p talloc functions to not need _p
authorAndrew Tridgell <tridge@samba.org>
Fri, 7 Jan 2005 04:39:16 +0000 (04:39 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:08:30 +0000 (13:08 -0500)
- added #if TALLOC_DEPRECATED around the _p functions

- fixes the code that broke from the above

while doing this I fixed quite a number of places that were
incorrectly using the non type-safe talloc functions to use the type
safe ones. Some were even doing multiplies for array allocation, which
is potentially unsafe.
(This used to be commit 6e7754abd0c225527fb38363996a6e241b87b37e)

39 files changed:
source4/auth/auth_sam.c
source4/dsdb/samdb/samdb.c
source4/include/includes.h
source4/lib/charcnv.c
source4/lib/registry/common/reg_util.c
source4/lib/talloc/talloc.c
source4/lib/talloc/talloc.h
source4/lib/talloc/talloc_guide.txt
source4/lib/talloc/testsuite.c
source4/libcli/auth/spnego_parse.c
source4/libcli/clilist.c
source4/libcli/ldap/ldap_ldif.c
source4/libcli/raw/rawnotify.c
source4/libcli/raw/rawrequest.c
source4/libcli/raw/rawtrans.c
source4/libcli/util/asn1.c
source4/librpc/ndr/libndr.h
source4/librpc/ndr/ndr.c
source4/librpc/rpc/dcerpc.c
source4/librpc/rpc/dcerpc_smb.c
source4/librpc/rpc/dcerpc_sock.c
source4/ntvfs/posix/pvfs_dirlist.c
source4/ntvfs/posix/pvfs_streams.c
source4/ntvfs/posix/xattr_system.c
source4/rpc_server/dcerpc_server.c
source4/smb_server/nttrans.c
source4/smb_server/reply.c
source4/smb_server/request.c
source4/smb_server/smb_server.c
source4/smb_server/trans2.c
source4/torture/gentest.c
source4/torture/local/idtree.c
source4/torture/rap/rap.c
source4/torture/raw/read.c
source4/torture/raw/search.c
source4/torture/raw/write.c
source4/torture/rpc/samsync.c
source4/torture/rpc/winreg.c
source4/utils/ndrdump.c

index 236a68fe9dd10440340fc1c825b91e19a948123a..a261fb223ff504499fd46ca2c0ef98965472a137 100644 (file)
@@ -379,7 +379,7 @@ NTSTATUS sam_make_server_info(TALLOC_CTX *mem_ctx, void *sam_ctx,
        }
        
        if (group_ret > 0 && 
-           !(groupSIDs = talloc_array_p(*server_info, struct dom_sid *, group_ret))) {
+           !(groupSIDs = talloc_array(*server_info, struct dom_sid *, group_ret))) {
                talloc_free(*server_info);
                return NT_STATUS_NO_MEMORY;
        }
index d84d07fca67be5bc29aa7ebd76865314d2468747..9dbf1f98822fdd1f8676dcc9ce5e844d57f8c4be 100644 (file)
@@ -858,7 +858,7 @@ int samdb_msg_add_hashes(void *ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg
        struct ldb_wrap *sam_ctx = ctx;
        struct ldb_val val;
        int i;
-       val.data = talloc_array(mem_ctx, 16, count, __location__);
+       val.data = talloc_array_size(mem_ctx, 16, count);
        val.length = count*16;
        if (!val.data) {
                return -1;
index 2666d59f898cdf54c37c65630ea84741c797f464..4d49a3b1ff4c0b3fec4527b8e669e3894b1b30b0 100644 (file)
@@ -154,6 +154,7 @@ extern int errno;
 /* Lists, trees, caching, database... */
 #include "version.h"
 #include "xfile.h"
+#define TALLOC_DEPRECATED 1
 #include "lib/talloc/talloc.h"
 #include "nt_status.h"
 #include "structs.h"
index 7e9750e94889c47daf60db4fd7c32042a3e52d43..d5727feb2c9e553fd9cd7eb1a1fe8a45d437a33b 100644 (file)
@@ -229,7 +229,7 @@ ssize_t convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
        outbuf = NULL;
 convert:
        destlen = 2 + (destlen*3);
-       ob = (char *)talloc_realloc(ctx, outbuf, destlen);
+       ob = talloc_realloc(ctx, outbuf, char, destlen);
        if (!ob) {
                DEBUG(0, ("convert_string_talloc: realloc failed!\n"));
                talloc_free(outbuf);
index 67c62fe5c86f82b0feb4d3d61b8455e95a8a007d..ef46dd61740b83b1558d64643cf3c09e9973c138 100644 (file)
@@ -63,7 +63,7 @@ char *reg_val_data_string(TALLOC_CTX *mem_ctx, struct registry_value *v)
          return ret;
 
   case REG_BINARY:
-         ret = talloc_array(mem_ctx, 3, v->data_len+1, "REG_BINARY");
+         ret = talloc_array_size(mem_ctx, 3, v->data_len+1);
          asciip = ret;
          for (i=0; i<v->data_len; i++) { 
                  int str_rem = v->data_len * 3 - (asciip - ret);
index bcadf40cfba4d12022d74be2d1ab16791969d762..6d11cb00e91435ae82e127c6303349cd42e0547a 100644 (file)
@@ -932,7 +932,7 @@ static char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap)
        }
        len = vsnprintf(NULL, 0, fmt, ap2);
 
-       s = talloc_realloc(NULL, s, s_len + len+1);
+       s = talloc_realloc(NULL, s, char, s_len + len+1);
        if (!s) return NULL;
 
        VA_COPY(ap2, ap);
@@ -961,7 +961,7 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...)
 /*
   alloc an array, checking for integer overflow in the array size
 */
-void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
+void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)
 {
        if (count >= MAX_TALLOC_SIZE/el_size) {
                return NULL;
@@ -972,7 +972,7 @@ void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *
 /*
   alloc an zero array, checking for integer overflow in the array size
 */
-void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
+void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name)
 {
        if (count >= MAX_TALLOC_SIZE/el_size) {
                return NULL;
@@ -984,16 +984,12 @@ void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const c
 /*
   realloc an array, checking for integer overflow in the array size
 */
-void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
+void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name)
 {
        if (count >= MAX_TALLOC_SIZE/el_size) {
                return NULL;
        }
-       ptr = talloc_realloc(ctx, ptr, el_size * count);
-       if (ptr) {
-               talloc_set_name_const(ptr, name);
-       }
-       return ptr;
+       return _talloc_realloc(ctx, ptr, el_size * count, name);
 }
 
 /*
index 747b1c6ba68e61fee784ca420a5844873bfcec1a..816978244157658ec695aea94b2a284ca89bd9ca 100644 (file)
@@ -32,17 +32,26 @@ typedef void TALLOC_CTX;
 #define __LINESTR__       _STRING_LINE2_(__LINE__)
 #define __location__ __FILE__ ":" __LINESTR__
 
+#ifndef TALLOC_DEPRECATED
+#define TALLOC_DEPRECATED 0
+#endif
+
 /* useful macros for creating type checked pointers */
 #define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
-#define talloc_p(ctx, type) talloc(ctx, type)
 #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
-#define talloc_zero(ctx, size) _talloc_zero(ctx, size, __location__)
-#define talloc_realloc(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
+
 #define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
-#define talloc_zero_p(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
-#define talloc_zero_array_p(ctx, type, count) (type *)talloc_zero_array(ctx, sizeof(type), count, __location__)
-#define talloc_array_p(ctx, type, count) (type *)talloc_array(ctx, sizeof(type), count, __location__)
-#define talloc_realloc_p(ctx, p, type, count) (type *)talloc_realloc_array(ctx, p, sizeof(type), count, __location__)
+
+#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
+#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
+
+#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, __location__)
+#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, __location__)
+#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
+
+#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, __location__)
+#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
+
 #define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
 
 #define talloc_destroy(ctx) talloc_free(ctx)
@@ -54,6 +63,14 @@ typedef void TALLOC_CTX;
 #define data_blob(ptr, size) data_blob_named(ptr, size, "DATA_BLOB: "__location__)
 #define data_blob_talloc(ctx, ptr, size) data_blob_talloc_named(ctx, ptr, size, "DATA_BLOB: "__location__)
 
+
+#if TALLOC_DEPRECATED
+#define talloc_zero_p(ctx, type) talloc_zero(ctx, type)
+#define talloc_p(ctx, type) talloc(ctx, type)
+#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count)
+#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count)
+#endif
+
 #ifndef PRINTF_ATTRIBUTE
 #define PRINTF_ATTRIBUTE(a1, a2)
 #endif
@@ -89,9 +106,9 @@ char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIB
 char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 char *talloc_asprintf_append(char *s,
                             const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
-void *talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
-void *talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
-void *talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
+void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
+void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
+void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
 void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
 void *talloc_autofree_context(void);
 
index af6bdf02752b05adeea5809413b6e9d056230f54..30b7f64d67f9300f47e8fbe7f2c48959e8ff373d 100644 (file)
@@ -5,7 +5,7 @@ Andrew Tridgell
 September 2004
 
 The most current version of this document is available at
-   http://samba.org/ftp/unpacked/samba4/talloc_guide.txt
+   http://samba.org/ftp/unpacked/samba4/source/lib/talloc/talloc_guide.txt
 
 If you are used to talloc from Samba3 then please read this carefully,
 as talloc has changed a lot.
@@ -19,7 +19,7 @@ between a "talloc context" and a "talloc pointer". Any pointer
 returned from talloc() is itself a valid talloc context. This means
 you can do this:
 
-  struct foo *X = talloc_p(mem_ctx, struct foo);
+  struct foo *X = talloc(mem_ctx, struct foo);
   X->name = talloc_strdup(X, "foo");
 
 and the pointer X->name would be a "child" of the talloc context "X"
@@ -34,7 +34,7 @@ talloc_free().
 
 If you find this confusing, then I suggest you run the LOCAL-TALLOC
 smbtorture test to watch talloc in action. You may also like to add
-your own tests to source/torture/local/talloc.c to clarify how some
+your own tests to source/lib/talloc/testsuite.c to clarify how some
 particular situation is handled.
 
 
@@ -270,13 +270,13 @@ particularly useful for creating a new temporary working context.
 
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_realloc(const void *context, void *ptr, size_t size);
+(type *)talloc_realloc(const void *context, void *ptr, type, count);
 
-The talloc_realloc() function changes the size of a talloc
+The talloc_realloc() macro changes the size of a talloc
 pointer. It has the following equivalences:
 
-  talloc_realloc(context, NULL, size) ==> talloc_size(context, size);
-  talloc_realloc(context, ptr, 0)     ==> talloc_free(ptr);
+  talloc_realloc(context, NULL, type, 1) ==> talloc(context, type);
+  talloc_realloc(context, ptr, type, 0)  ==> talloc_free(ptr);
 
 The "context" argument is only used if "ptr" is not NULL, otherwise it
 is ignored.
@@ -286,6 +286,13 @@ will fail either due to a lack of memory, or because the pointer has
 more than one parent (see talloc_reference()).
 
 
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+void *talloc_realloc_size(const void *context, void *ptr, size_t size);
+
+the talloc_realloc_size() function is useful when the type is not 
+known so the typesafe talloc_realloc() cannot be used.
+
+
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 void *talloc_steal(const void *new_ctx, const void *ptr);
 
@@ -403,12 +410,18 @@ full talloc report on 'root' (total 18 bytes in 8 blocks)
 
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_zero(const void *ctx, size_t size);
+(type *)talloc_zero(const void *ctx, type);
 
-The talloc_zero() function is equivalent to:
+The talloc_zero() macro is equivalent to:
 
-  ptr = talloc_size(ctx, size);
-  if (ptr) memset(ptr, 0, size);
+  ptr = talloc(ctx, type);
+  if (ptr) memset(ptr, 0, sizeof(type));
+
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+void *talloc_zero_size(const void *ctx, size_t size)
+
+The talloc_zero_size() function is useful when you don't have a known type
 
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
@@ -469,25 +482,19 @@ string to the given string.
 
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_array_p(const void *ctx, type, uint_t count);
+(type *)talloc_array(const void *ctx, type, uint_t count);
 
-The talloc_array_p() macro is equivalent to:
+The talloc_array() macro is equivalent to:
 
   (type *)talloc_size(ctx, sizeof(type) * count);
 
 except that it provides integer overflow protection for the multiply,
 returning NULL if the multiply overflows.
 
-
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-void *talloc_realloc_p(const void *ctx, void *ptr, type, uint_t count);
-
-The talloc_realloc_p() macro is equivalent to:
+void *talloc_array_size(const void *ctx, size_t size, uint_t count);
 
-  (type *)talloc_realloc(ctx, ptr, sizeof(type) * count);
-
-except that it provides integer overflow protection for the multiply,
-returning NULL if the multiply overflows.
+The talloc_array_size() function is useful when the type is not known
 
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
index d46964d9b64e43df88162cf440d7543225c66b43..e7934a10f3ad3a72b4ead19932c08b5fc24488cc 100644 (file)
@@ -398,7 +398,7 @@ static BOOL test_misc(void)
        talloc_report(root, stdout);
 
 
-       p2 = talloc_zero(p1, 20);
+       p2 = talloc_zero_size(p1, 20);
        if (p2[19] != 0) {
                printf("Failed to give zero memory\n");
                return False;
@@ -520,41 +520,41 @@ static BOOL test_realloc(void)
        p1 = talloc_size(root, 10);
        CHECK_SIZE(p1, 10);
 
-       p1 = talloc_realloc(NULL, p1, 20);
+       p1 = talloc_realloc_size(NULL, p1, 20);
        CHECK_SIZE(p1, 20);
 
        talloc_new(p1);
 
-       p2 = talloc_realloc(p1, NULL, 30);
+       p2 = talloc_realloc_size(p1, NULL, 30);
 
        talloc_new(p1);
 
-       p2 = talloc_realloc(p1, p2, 40);
+       p2 = talloc_realloc_size(p1, p2, 40);
 
        CHECK_SIZE(p2, 40);
        CHECK_SIZE(root, 60);
        CHECK_BLOCKS(p1, 4);
 
-       p1 = talloc_realloc(NULL, p1, 20);
+       p1 = talloc_realloc_size(NULL, p1, 20);
        CHECK_SIZE(p1, 60);
 
        talloc_increase_ref_count(p2);
-       if (talloc_realloc(NULL, p2, 5) != NULL) {
+       if (talloc_realloc_size(NULL, p2, 5) != NULL) {
                printf("failed: talloc_realloc() on a referenced pointer should fail\n");
                return False;
        }
        CHECK_BLOCKS(p1, 4);
 
-       talloc_realloc(NULL, p2, 0);
-       talloc_realloc(NULL, p2, 0);
+       talloc_realloc_size(NULL, p2, 0);
+       talloc_realloc_size(NULL, p2, 0);
        CHECK_BLOCKS(p1, 3);
 
-       if (talloc_realloc(NULL, p1, 0x7fffffff) != NULL) {
+       if (talloc_realloc_size(NULL, p1, 0x7fffffff) != NULL) {
                printf("failed: oversize talloc should fail\n");
                return False;
        }
 
-       talloc_realloc(NULL, p1, 0);
+       talloc_realloc_size(NULL, p1, 0);
 
        CHECK_BLOCKS(root, 1);
        CHECK_SIZE(root, 0);
index 32e98a42354e6c8d9f0c637cc1e9593d5ddd538b..78a94a6a44ae76563669dbe3487e38e73bcf45fb 100644 (file)
@@ -52,9 +52,9 @@ static BOOL read_negTokenInit(struct asn1_data *asn1, struct spnego_negTokenInit
                        token->mechTypes = talloc_p(NULL, const char *);
                        for (i = 0; !asn1->has_error &&
                                     0 < asn1_tag_remaining(asn1); i++) {
-                               token->mechTypes = 
-                                       talloc_realloc(NULL, token->mechTypes, (i + 2) *
-                                                      sizeof(*token->mechTypes));
+                               token->mechTypes = talloc_realloc(NULL, 
+                                                                 token->mechTypes, 
+                                                                 const char *, i+2);
                                asn1_read_OID(asn1, token->mechTypes + i);
                                if (token->mechTypes[i]) {
                                        talloc_steal(token->mechTypes, 
index ec103dbfa415de6139864560805a8375b59278c1..77fd760837ca1664625d4037da9e561f95157c04 100644 (file)
@@ -81,13 +81,13 @@ static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file)
        /* add file info to the dirlist pool */
        tdl = talloc_realloc(state, 
                             state->dirlist,
-                            state->dirlist_len + sizeof(struct clilist_file_info));
-
+                            struct clilist_file_info,
+                            state->dirlist_len + 1);
        if (!tdl) {
                return False;
        }
        state->dirlist = tdl;
-       state->dirlist_len += sizeof(struct clilist_file_info);
+       state->dirlist_len++;
 
        interpret_long_filename(state->info_level, file, &state->dirlist[state->total_received]);
 
@@ -227,13 +227,14 @@ static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file)
        /* add file info to the dirlist pool */
        tdl = talloc_realloc(state,
                             state->dirlist,
-                            state->dirlist_len + sizeof(struct clilist_file_info));
+                            struct clilist_file_info,
+                            state->dirlist_len + 1);
 
        if (!tdl) {
                return False;
        }
        state->dirlist = tdl;
-       state->dirlist_len += sizeof(struct clilist_file_info);
+       state->dirlist_len++;
 
        interpret_short_filename(state->info_level, file, &state->dirlist[state->total_received]);
 
index c276b7e917ae8ededccf4deb1eb865c04dba9f64..809c75cf962c06cf2392f8127646a296de054293 100644 (file)
@@ -52,7 +52,7 @@ static char *next_chunk(TALLOC_CTX *mem_ctx,
                if (chunk_size+1 >= alloc_size) {
                        char *c2;
                        alloc_size += 1024;
-                       c2 = talloc_realloc(mem_ctx, chunk, alloc_size);
+                       c2 = talloc_realloc(mem_ctx, chunk, char, alloc_size);
                        if (!c2) {
                                errno = ENOMEM;
                                return NULL;
index 918fb788cbd261eabcae202ff0684ea2ff6caa20..e48545419fd332f4b920997da4803dff85903354 100644 (file)
@@ -73,7 +73,7 @@ NTSTATUS smb_raw_changenotify_recv(struct smbcli_request *req,
        }
 
        /* allocate array */
-       parms->out.changes = talloc_array_p(mem_ctx, struct notify_changes, parms->out.num_changes);
+       parms->out.changes = talloc_array(mem_ctx, struct notify_changes, parms->out.num_changes);
        if (!parms->out.changes) {
                return NT_STATUS_NO_MEMORY;
        }
index b74f066ef464a5066a8d7978809c24986079c192..8093b298bbfbf61013780b51b7852223382ddf16 100644 (file)
@@ -203,7 +203,7 @@ static void smbcli_req_grow_allocation(struct smbcli_request *req, uint_t new_si
 
        /* we need to realloc */
        req->out.allocated = req->out.size + delta + REQ_OVER_ALLOCATION;
-       buf2 = talloc_realloc(req, req->out.buffer, req->out.allocated);
+       buf2 = talloc_realloc(req, req->out.buffer, uint8_t, req->out.allocated);
        if (buf2 == NULL) {
                smb_panic("out of memory in req_grow_allocation");
        }
@@ -950,7 +950,7 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
 
        max_len = (strlen(str)+2) * MAX_BYTES_PER_CHAR;         
 
-       blob->data = talloc_realloc(mem_ctx, blob->data, blob->length + max_len);
+       blob->data = talloc_realloc(mem_ctx, blob->data, uint8_t, blob->length + max_len);
        if (!blob->data) {
                return 0;
        }
index 0ccecdc2d46b4ec8453925129c31dae93458be7b..118ac5e3fdf90743d98ab7a81e3d2a6216a725c3 100644 (file)
@@ -111,7 +111,7 @@ NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req,
 
        if (parms->out.setup_count > 0) {
                int i;
-               parms->out.setup = talloc_array(mem_ctx, 2, parms->out.setup_count, "setup");
+               parms->out.setup = talloc_array(mem_ctx, uint16_t, parms->out.setup_count);
                if (!parms->out.setup) {
                        req->status = NT_STATUS_NO_MEMORY;
                        return smbcli_request_destroy(req);
@@ -439,7 +439,7 @@ NTSTATUS smb_raw_nttrans_recv(struct smbcli_request *req,
 
        if (parms->out.setup_count > 0) {
                int i;
-               parms->out.setup = talloc_array(mem_ctx, 2, parms->out.setup_count, "setup");
+               parms->out.setup = talloc_array(mem_ctx, uint16_t, parms->out.setup_count);
                if (!parms->out.setup) {
                        req->status = NT_STATUS_NO_MEMORY;
                        return smbcli_request_destroy(req);
index 52ba0225c9f5f0167c936e9cae3e542d574f5098..de14eb0e578164eed1dd217e95fe8cbce8fbc99a 100644 (file)
@@ -33,7 +33,7 @@ BOOL asn1_write(struct asn1_data *data, const void *p, int len)
        if (data->has_error) return False;
        if (data->length < data->ofs+len) {
                uint8_t *newp;
-               newp = talloc_realloc(NULL, data->data, data->ofs+len);
+               newp = talloc_realloc(NULL, data->data, uint8_t, data->ofs+len);
                if (!newp) {
                        asn1_free(data);
                        data->has_error = True;
index aebd9892ba7a657fffa1b5e966a21737804b36ad..288e753ccae58d4654236142c1b987648d448c82 100644 (file)
@@ -239,7 +239,7 @@ enum ndr_err_code {
 
 
 #define NDR_ALLOC_N_SIZE(ndr, s, n, elsize) do { \
-       (s) = talloc_array(ndr, elsize, n, __location__); \
+       (s) = talloc_array_size(ndr, elsize, n); \
        if (!(s)) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Alloc %u * %u failed\n", n, elsize); \
 } while (0)
 
index 9ec22cdb7945e6f2d9445f59950f84f331d545f6..7cc832c68e30ccb442d353457be759523281eae0 100644 (file)
@@ -173,7 +173,7 @@ NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32_t size)
        if (size > ndr->alloc_size) {
                ndr->alloc_size = size;
        }
-       ndr->data = talloc_realloc(ndr, ndr->data, ndr->alloc_size);
+       ndr->data = talloc_realloc(ndr, ndr->data, uint8_t, ndr->alloc_size);
        if (!ndr->data) {
                return ndr_push_error(ndr, NDR_ERR_ALLOC, "Failed to push_expand to %u",
                                      ndr->alloc_size);
index 9a8de8c0ad610ecd7b0c1c5cf8c0e4095c3c81f6..ee7250a4f9cefbe4802da8cf54feb0129be2a244 100644 (file)
@@ -811,6 +811,7 @@ static void dcerpc_request_recv_data(struct dcerpc_pipe *p,
        if (length > 0) {
                req->payload.data = talloc_realloc(req, 
                                                   req->payload.data, 
+                                                  uint8_t,
                                                   req->payload.length + length);
                if (!req->payload.data) {
                        req->status = NT_STATUS_NO_MEMORY;
index d04b067eeb740d22349d658dfaf59536be96938b..ab8a60b06039f05a354000aaf83b7f1fd337c074 100644 (file)
@@ -94,7 +94,7 @@ static void smb_read_callback(struct smbcli_request *req)
        }
 
        /* initiate another read request, as we only got part of a fragment */
-       state->data.data = talloc_realloc(state, state->data.data, frag_length);
+       state->data.data = talloc_realloc(state, state->data.data, uint8_t, frag_length);
 
        io->readx.in.mincnt = MIN(state->p->srv_max_xmit_frag, 
                                  frag_length - state->received);
index 8de43d845495e00445f25e616db4021db0f893e0..762a22ad3e174cd1fa46805d796dd1b336ae6ed9 100644 (file)
@@ -151,7 +151,7 @@ static void sock_process_recv(struct dcerpc_pipe *p)
                frag_length = dcerpc_get_frag_length(&sock->recv.data);
 
                sock->recv.data.data = talloc_realloc(sock, sock->recv.data.data,
-                                                    frag_length);
+                                                     uint8_t, frag_length);
                if (sock->recv.data.data == NULL) {
                        sock_dead(p, NT_STATUS_NO_MEMORY);
                        return;
index 5c67b2d189d1ac4535f86558475f6ddd1ee1ae7d..c2e8f826a2bef639deec0107170aad548766612b 100644 (file)
@@ -137,9 +137,9 @@ NTSTATUS pvfs_list_start(struct pvfs_state *pvfs, struct pvfs_filename *name,
        dir->no_wildcard = False;
        dir->end_of_search = False;
        dir->offset = 0;
-       dir->name_cache = talloc_zero_array_p(dir, 
-                                             struct name_cache_entry, 
-                                             NAME_CACHE_SIZE);
+       dir->name_cache = talloc_zero_array(dir, 
+                                           struct name_cache_entry, 
+                                           NAME_CACHE_SIZE);
        if (dir->name_cache == NULL) {
                talloc_free(dir);
                return NT_STATUS_NO_MEMORY;
index 12f783e1729c7112642031f261a45edb659bfcc0..e92732b810ffa01f16ef9bd1b22c783b65ba5e3b 100644 (file)
@@ -283,7 +283,7 @@ ssize_t pvfs_stream_write(struct pvfs_state *pvfs,
                blob = data_blob(NULL, 0);
        }
        if (count+offset > blob.length) {
-               blob.data = talloc_realloc(blob.data, blob.data, count+offset);
+               blob.data = talloc_realloc(blob.data, blob.data, uint8_t, count+offset);
                if (blob.data == NULL) {
                        errno = ENOMEM;
                        return -1;
@@ -339,7 +339,7 @@ NTSTATUS pvfs_stream_truncate(struct pvfs_state *pvfs,
        if (length <= blob.length) {
                blob.length = length;
        } else if (length > blob.length) {
-               blob.data = talloc_realloc(blob.data, blob.data, length);
+               blob.data = talloc_realloc(blob.data, blob.data, uint8_t, length);
                if (blob.data == NULL) {
                        return NT_STATUS_NO_MEMORY;
                }
index c86ee0bd871164c8b9da9ba37fb7a1a378f92dcb..f19177f44c7e44383af5219c017b69dffe2e04aa 100644 (file)
@@ -51,7 +51,8 @@ again:
        }
        if (ret == -1 && errno == ERANGE) {
                estimated_size *= 2;
-               blob->data = talloc_realloc(mem_ctx, blob->data, estimated_size);
+               blob->data = talloc_realloc(mem_ctx, blob->data, 
+                                           uint8_t, estimated_size);
                if (blob->data == NULL) {
                        return NT_STATUS_NO_MEMORY;
                }
index c53036b45b7261d057c043e7054c7ca0f2e6c420..f0791e592818f426f1239e67dd540b0ebd79ee07 100644 (file)
@@ -857,7 +857,9 @@ NTSTATUS dcesrv_input_process(struct dcesrv_connection *dce_conn)
                }
 
                call->pkt.u.request.stub_and_verifier.data = 
-                       talloc_realloc(call, call->pkt.u.request.stub_and_verifier.data, alloc_size);
+                       talloc_realloc(call, 
+                                      call->pkt.u.request.stub_and_verifier.data, 
+                                      uint8_t, alloc_size);
                if (!call->pkt.u.request.stub_and_verifier.data) {
                        return dcesrv_fault(call2, DCERPC_FAULT_OTHER);
                }
@@ -920,6 +922,7 @@ NTSTATUS dcesrv_input(struct dcesrv_connection *dce_conn, const DATA_BLOB *data)
 
        dce_conn->partial_input.data = talloc_realloc(dce_conn,
                                                      dce_conn->partial_input.data,
+                                                     uint8_t,
                                                      dce_conn->partial_input.length + data->length);
        if (!dce_conn->partial_input.data) {
                return NT_STATUS_NO_MEMORY;
index 0ab9c9ce2eaa04b1ecd1ebb6d80f0d3a5cf55e77..58755542586751f5259db3e8a2015e4c767ef021 100644 (file)
@@ -42,7 +42,7 @@ static void nttrans_setup_reply(struct smbsrv_request *req,
 {
        trans->out.setup_count = setup_count;
        if (setup_count != 0) {
-               trans->out.setup = talloc_zero_array_p(req, uint16_t, setup_count);
+               trans->out.setup = talloc_zero_array(req, uint16_t, setup_count);
        }
        trans->out.params = data_blob_talloc(req, NULL, param_size);
        trans->out.data = data_blob_talloc(req, NULL, data_size);
index 0b49512663c7d0b0aec2026f234ffcf912d37483..2dfa3726e2b67ecfd630cf20d3ed9176b43e4e96 100644 (file)
@@ -2377,7 +2377,7 @@ void reply_sendtxt(struct smbsrv_request *req)
 void reply_special(struct smbsrv_request *req)
 {
        uint8_t msg_type;
-       uint8_t *buf = talloc_zero_array_p(req, uint8_t, 4);
+       uint8_t *buf = talloc_zero_array(req, uint8_t, 4);
        
        msg_type = CVAL(req->in.buffer,0);
 
index bd33e8cfc76cea7f36a5f516980674359b34a26c..2ac832b439dc0b8bb9fe316cca0b1d313b13438c 100644 (file)
@@ -83,7 +83,8 @@ static void req_setup_chain_reply(struct smbsrv_request *req, uint_t wct, uint_t
        /* over allocate by a small amount */
        req->out.allocated = req->out.size + REQ_OVER_ALLOCATION; 
 
-       req->out.buffer = talloc_realloc(req, req->out.buffer, req->out.allocated);
+       req->out.buffer = talloc_realloc(req, req->out.buffer, 
+                                        uint8_t, req->out.allocated);
        if (!req->out.buffer) {
                smbsrv_terminate_connection(req->smb_conn, "allocation failed");
                return;
@@ -236,7 +237,7 @@ static void req_grow_allocation(struct smbsrv_request *req, uint_t new_size)
 
        /* we need to realloc */
        req->out.allocated = req->out.size + delta + REQ_OVER_ALLOCATION;
-       buf2 = talloc_realloc(req, req->out.buffer, req->out.allocated);
+       buf2 = talloc_realloc(req, req->out.buffer, uint8_t, req->out.allocated);
        if (buf2 == NULL) {
                smb_panic("out of memory in req_grow_allocation");
        }
index 2ebb927f1ea0b32e12cf7cdeb066e3b700a03ea1..0e845b969754a5afee62c060231a191e5059a5c9 100644 (file)
@@ -108,7 +108,8 @@ static NTSTATUS receive_smb_request(struct smbsrv_connection *smb_conn, struct t
                /* when we have a full NBT header, then allocate the packet */
                if (req->in.size == NBT_HDR_SIZE) {
                        len = smb_len(req->in.buffer) + NBT_HDR_SIZE;
-                       req->in.buffer = talloc_realloc(req, req->in.buffer, len);
+                       req->in.buffer = talloc_realloc(req, req->in.buffer, 
+                                                       uint8_t, len);
                        if (req->in.buffer == NULL) {
                                return NT_STATUS_NO_MEMORY;
                        }
index 8aa60daa6df43d7028caa215b94fa73477eaf74b..2b9573383fcd0a3b9ba68665c30b2af2f1a47fd9 100644 (file)
@@ -42,7 +42,8 @@ static BOOL trans2_grow_data_allocation(struct smbsrv_request *req,
        if (new_size <= trans->out.data.length) {
                return True;
        }
-       trans->out.data.data = talloc_realloc(req, trans->out.data.data, new_size);
+       trans->out.data.data = talloc_realloc(req, trans->out.data.data, 
+                                             uint8_t, new_size);
        return (trans->out.data.data != NULL);
 }
 
@@ -83,7 +84,7 @@ static void trans2_setup_reply(struct smbsrv_request *req,
 {
        trans->out.setup_count = setup_count;
        if (setup_count != 0) {
-               trans->out.setup = talloc_zero_array_p(req, uint16_t, setup_count);
+               trans->out.setup = talloc_zero_array(req, uint16_t, setup_count);
        }
        trans->out.params = data_blob_talloc(req, NULL, param_size);
        trans->out.data = data_blob_talloc(req, NULL, data_size);
index 5d8c7bf8fdbc6d6583ba0140ec8016f87ff67904..81e2a59f345f095fdc070b2fd9d8c638ce66215e 100644 (file)
@@ -1358,7 +1358,7 @@ static BOOL handler_writex(int instance)
        parm[0].writex.in.wmode = gen_bits_mask(0xFFFF);
        parm[0].writex.in.remaining = gen_io_count();
        parm[0].writex.in.count = gen_io_count();
-       parm[0].writex.in.data = talloc_zero(current_op.mem_ctx, parm[0].writex.in.count);
+       parm[0].writex.in.data = talloc_zero_size(current_op.mem_ctx, parm[0].writex.in.count);
 
        GEN_COPY_PARM;
        GEN_SET_FNUM(writex.in.fnum);
index 3f30d7123fdd06066d9f56baa9946dab810267c7..94463cefa690d92a41c19643d5d09e1fcc1e9313 100644 (file)
@@ -35,8 +35,8 @@ BOOL torture_local_idtree(void)
 
        idr = idr_init(ctx);
 
-       ids = talloc_zero_array_p(ctx, int, n);
-       present = talloc_zero_array_p(ctx, int, n);
+       ids = talloc_zero_array(ctx, int, n);
+       present = talloc_zero_array(ctx, int, n);
 
        for (i=0;i<n;i++) {
                ids[i] = -1;
index b47cfa2997a56b6fc2dc44fa407df0fb2d608f3e..0080a80951e69db2c72237a29dd924cab8120d9f 100644 (file)
@@ -82,6 +82,7 @@ static void rap_cli_push_paramdesc(struct rap_call *call, char desc)
 
        call->paramdesc = talloc_realloc(call->mem_ctx,
                                         call->paramdesc,
+                                        uint8_t,
                                         len+2);
        call->paramdesc[len] = desc;
        call->paramdesc[len+1] = '\0';
@@ -151,7 +152,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr,
        if ( string_offset + len + 1 >  ndr->data_size )
                return NT_STATUS_INVALID_PARAMETER;
 
-       *dest = talloc_zero(mem_ctx, len+1);
+       *dest = talloc_zero_size(mem_ctx, len+1);
        pull_ascii(*dest, p, len+1, len, 0);
 
        return NT_STATUS_OK;
index 12818f7ba66ffd71762830e2ea81088d2c3f7b8e..fb2e2ddec21fdc062fed8883e5ff928e24e9a5db 100644 (file)
@@ -90,7 +90,7 @@ static BOOL test_read(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        const char *test_data = "TEST DATA";
        uint_t seed = time(NULL);
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
@@ -214,7 +214,7 @@ static BOOL test_lockread(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        const char *test_data = "TEST DATA";
        uint_t seed = time(NULL);
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
@@ -357,7 +357,7 @@ static BOOL test_readx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        const char *test_data = "TEST DATA";
        uint_t seed = time(NULL);
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
@@ -551,7 +551,7 @@ static BOOL test_readbraw(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        const char *test_data = "TEST DATA";
        uint_t seed = time(NULL);
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
index 55acaba2b2cd915592c61e25afb72863a16761ff..84466d0cdeb5f01c7b41f6d73c746a7d038af17e 100644 (file)
@@ -960,9 +960,9 @@ static BOOL test_many_dirs(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
                smbcli_close(cli->tree, fnum);
        }
 
-       file  = talloc_zero_array_p(mem_ctx, union smb_search_data, num_dirs);
-       file2 = talloc_zero_array_p(mem_ctx, union smb_search_data, num_dirs);
-       file3 = talloc_zero_array_p(mem_ctx, union smb_search_data, num_dirs);
+       file  = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
+       file2 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
+       file3 = talloc_zero_array(mem_ctx, union smb_search_data, num_dirs);
 
        printf("Search first on %d dirs\n", num_dirs);
 
index 06fbe667eab2a32cbc669a0af8ee41fb765129d8..698520258dd331464b96e08bf0e84768dfce990f 100644 (file)
@@ -104,7 +104,7 @@ static BOOL test_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        uint_t seed = time(NULL);
        union smb_fileinfo finfo;
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
@@ -221,7 +221,7 @@ static BOOL test_writex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        uint_t seed = time(NULL);
        union smb_fileinfo finfo;
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
@@ -397,7 +397,7 @@ static BOOL test_writeunlock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        uint_t seed = time(NULL);
        union smb_fileinfo finfo;
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
@@ -534,7 +534,7 @@ static BOOL test_writeclose(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        uint_t seed = time(NULL);
        union smb_fileinfo finfo;
 
-       buf = talloc_zero(mem_ctx, maxsize);
+       buf = talloc_zero_size(mem_ctx, maxsize);
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
index 86e10678c9396050f844d103af0dd63810de37d4..4c47870015dabaa03e4a707eaaa6790791813a3c 100644 (file)
@@ -878,7 +878,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
 
        TEST_SEC_DESC_EQUAL(account->sdbuf, lsa, &acct_handle);
 
-       found_priv_in_lsa = talloc_zero_array_p(mem_ctx, BOOL, account->privilege_entries);
+       found_priv_in_lsa = talloc_zero_array(mem_ctx, BOOL, account->privilege_entries);
 
        e.in.handle = &acct_handle;
 
index 14c18df370cdbb7341280cd179b54f94e6d09ca1..9e24a9f05552144b276f6cee1e19a7d68c88c28e 100644 (file)
@@ -367,7 +367,7 @@ static BOOL test_QueryMultipleValues(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
        r.in.num_values = 1;
        r.in.buffer_size = r.out.buffer_size = talloc_p(mem_ctx, uint32);
        *r.in.buffer_size = 0x20;
-       r.in.buffer = r.out.buffer = talloc_zero_array_p(mem_ctx, uint8, *r.in.buffer_size);
+       r.in.buffer = r.out.buffer = talloc_zero_array(mem_ctx, uint8, *r.in.buffer_size);
 
        status = dcerpc_winreg_QueryMultipleValues(p, mem_ctx, &r);
        if(NT_STATUS_IS_ERR(status)) {
index c5867f85f1c7a2e966407d865ab0eb98555e58d3..1b80ea1825233a0fa622a6da30cf60446e1a780b 100644 (file)
@@ -146,7 +146,7 @@ static void show_functions(const struct dcerpc_interface_table *p)
 
        mem_ctx = talloc_init("ndrdump");
 
-       st = talloc_zero(mem_ctx, f->struct_size);
+       st = talloc_zero_size(mem_ctx, f->struct_size);
        if (!st) {
                printf("Unable to allocate %d bytes\n", f->struct_size);
                exit(1);