]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: Replace a few calls to TALLOC() with talloc_array()
authorVolker Lendecke <vl@samba.org>
Fri, 17 Oct 2025 12:24:02 +0000 (14:24 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 10 Nov 2025 13:29:30 +0000 (13:29 +0000)
No explicit cast necessary

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/printing/notify.c
source3/rpc_client/cli_winreg.c
source3/rpc_client/cli_winreg_spoolss.c
source3/torture/pdbtest.c
source3/utils/net_rpc_registry.c

index 8312b0b612d94b4eb365bcb171bad38c6f459bf0..80c2a94d1e6f8685c173fc59a17f8b12cc88cc0f 100644 (file)
@@ -156,7 +156,7 @@ static void print_notify_send_messages_to_printer(struct messaging_context *msg_
        }
        offset += 4; /* For count. */
 
-       buf = (char *)TALLOC(send_ctx, offset);
+       buf = talloc_array(send_ctx, char, offset);
        if (!buf) {
                DEBUG(0,("print_notify_send_messages: Out of memory\n"));
                talloc_free_children(send_ctx);
index a360d1eabcba6e354dfb210ed008170c670a6754..42db8e0eac39eb0ed360457dc7a0dca6ea464e48 100644 (file)
@@ -797,7 +797,7 @@ NTSTATUS dcerpc_winreg_enumvals(TALLOC_CTX *mem_ctx,
                data_size = max_valbufsize;
                data = NULL;
                if (data_size) {
-                       data = (uint8_t *) TALLOC(tmp_ctx, data_size);
+                       data = talloc_array(tmp_ctx, uint8_t, data_size);
                }
                length = 0;
 
index ca46ae5301255fc45666cc3e41c6f8d550b1151c..ef698db00634f1cba430a3fd15375fa86bb6f6bd 100644 (file)
@@ -2263,7 +2263,7 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       data_in = (uint8_t *) TALLOC(tmp_ctx, data_in_size);
+       data_in = talloc_array(tmp_ctx, uint8_t, data_in_size);
        if (data_in == NULL) {
                result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
@@ -3298,7 +3298,7 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       data_in = (uint8_t *) TALLOC(tmp_ctx, data_in_size);
+       data_in = talloc_array(tmp_ctx, uint8_t, data_in_size);
        if (data_in == NULL) {
                result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
index d153f3e56c8c7fd7d5f91e035c838850fe8e4f89..059aceaa1d043bf7a6834690cb065b76ad25d8d3 100644 (file)
@@ -636,9 +636,11 @@ int main(int argc, const char **argv)
 
        pdb_get_account_policy(PDB_POLICY_PASSWORD_HISTORY, &history);
        if (history * PW_HISTORY_ENTRY_LEN < NT_HASH_LEN) {
-               buf = (uint8_t *)TALLOC(ctx, NT_HASH_LEN);
+               buf = talloc_array(ctx, uint8_t, NT_HASH_LEN);
        } else {
-               buf = (uint8_t *)TALLOC(ctx, history * PW_HISTORY_ENTRY_LEN);
+               buf = talloc_array(ctx,
+                                  uint8_t,
+                                  history * PW_HISTORY_ENTRY_LEN);
        }
 
        /* Generate some random hashes */
index cec545902c76ade881226bad317a89cb16a2b55b..f474317c0530365b48066fb2670c7153099b7259 100644 (file)
@@ -356,7 +356,7 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx,
                name_buf.size = max_valnamelen + 2;
 
                data_size = max_valbufsize;
-               data = (uint8_t *)TALLOC(mem_ctx, data_size);
+               data = talloc_array(mem_ctx, uint8_t, data_size);
                value_length = 0;
 
                status = dcerpc_winreg_EnumValue(b, mem_ctx, key_hnd,
@@ -479,7 +479,7 @@ static NTSTATUS registry_enumvalues2(TALLOC_CTX *ctx,
                name_buf.size = max_valnamelen + 2;
 
                data_size = max_valbufsize;
-               data = (uint8_t *)TALLOC(mem_ctx, data_size);
+               data = talloc_array(mem_ctx, uint8_t, data_size);
                value_length = 0;
 
                status = dcerpc_winreg_EnumValue(b, mem_ctx, key_hnd,