]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Save lines by avoiding explicit ZERO_STRUCTP calls
authorVolker Lendecke <vl@samba.org>
Fri, 4 Apr 2025 10:24:59 +0000 (12:24 +0200)
committerVolker Lendecke <vl@samba.org>
Thu, 15 May 2025 14:03:34 +0000 (14:03 +0000)
SMB_CALLOC_ARRAY(..., 1) does this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/auth/pampass.c
source3/lib/interface.c
source3/modules/vfs_readahead.c
source3/modules/vfs_shadow_copy.c
source3/printing/printing_db.c
source3/registry/regfio.c
source3/winbindd/winbindd_cache.c

index 0be7f9f9d1fb3d50f5d17c3c7425877b5091a407..03d2fe69286c5a26ec3caf387445188645de2bae 100644 (file)
@@ -236,15 +236,13 @@ static struct chat_struct *make_pw_chat(const char *p)
        TALLOC_CTX *frame = talloc_stackframe();
 
        while (1) {
-               t = SMB_MALLOC_P(struct chat_struct);
+               t = SMB_CALLOC_ARRAY(struct chat_struct, 1);
                if (!t) {
                        DEBUG(0,("make_pw_chat: malloc failed!\n"));
                        TALLOC_FREE(frame);
                        return NULL;
                }
 
-               ZERO_STRUCTP(t);
-
                DLIST_ADD_END(list, t);
 
                if (!next_token_talloc(frame, &p, &prompt, NULL)) {
index 5f351999e41ffd04451f38fb3ca3b2e1b02fe3d9..4fbc17cccb7e1efab07ecf40f4cd3150f880b457 100644 (file)
@@ -319,13 +319,11 @@ static void add_interface(const struct iface_struct *ifs)
                return;
        }
 
-       iface = SMB_MALLOC_P(struct interface);
+       iface = SMB_CALLOC_ARRAY(struct interface, 1);
        if (!iface) {
                return;
        }
 
-       ZERO_STRUCTPN(iface);
-
        iface->name = SMB_STRDUP(ifs->name);
        if (!iface->name) {
                SAFE_FREE(iface);
index bb31b578b95c8ec878d00036bf043e6dfa9e89d6..15f23e3f77d547cd7fd70469856df51cef3304e9 100644 (file)
@@ -139,13 +139,12 @@ static int readahead_connect(struct vfs_handle_struct *handle,
        if (ret < 0) {
                return ret;
        }
-       rhd = SMB_MALLOC_P(struct readahead_data);
+       rhd = SMB_CALLOC_ARRAY(struct readahead_data, 1);
        if (!rhd) {
                SMB_VFS_NEXT_DISCONNECT(handle);
                DEBUG(0,("readahead_connect: out of memory\n"));
                return -1;
        }
-       ZERO_STRUCTP(rhd);
 
        rhd->didmsg = False;
        rhd->off_bound = conv_str_size(lp_parm_const_string(SNUM(handle->conn),
index 62b929188861a90cc227080bf8fd22aed1546f9c..c99d933a5d3ef5e3710c4c9e61468a9eedd59bbe 100644 (file)
@@ -85,7 +85,7 @@ static DIR *shadow_copy_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
                return NULL;
        }
 
-       dirp = SMB_MALLOC_P(shadow_copy_Dir);
+       dirp = SMB_CALLOC_ARRAY(shadow_copy_Dir, 1);
        if (!dirp) {
                DEBUG(0,("shadow_copy_fdopendir: Out of memory\n"));
                SMB_VFS_NEXT_CLOSEDIR(handle,p);
@@ -94,8 +94,6 @@ static DIR *shadow_copy_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
                return NULL;
        }
 
-       ZERO_STRUCTP(dirp);
-
        while (True) {
                struct dirent *d;
 
index d54a39a9922bdd9a3f724edc030de8067ad89013..ee538e2999b7e5488f5a08607b98fe2577e51fe6 100644 (file)
@@ -87,12 +87,11 @@ struct tdb_print_db *get_print_db_byname(const char *printername)
 
        if (!p) {
                /* Create one. */
-               p = SMB_MALLOC_P(struct tdb_print_db);
+               p = SMB_CALLOC_ARRAY(struct tdb_print_db, 1);
                if (!p) {
                        DEBUG(0,("get_print_db: malloc fail !\n"));
                        return NULL;
                }
-               ZERO_STRUCTP(p);
                DLIST_ADD(print_db_head, p);
        }
 
index 2ddac2179b24cef4f68452e391f5e8a8b34bbda7..a9b8ce8b7e4f5936571c645717bf1da409751d93 100644 (file)
@@ -1240,11 +1240,10 @@ out:
 {
        REGF_FILE *rb;
 
-       if ( !(rb = SMB_MALLOC_P(REGF_FILE)) ) {
+       if (!(rb = SMB_CALLOC_ARRAY(REGF_FILE, 1))) {
                DEBUG(0,("ERROR allocating memory\n"));
                return NULL;
        }
-       ZERO_STRUCTP( rb );
        rb->fd = -1;
        rb->ignore_checksums = false;
 
index 7a000c482592078a5823d8d2f37ca1b7d66627ed..96fee6c4218957ece2920b282d99ca3df3c920e1 100644 (file)
@@ -3467,14 +3467,12 @@ static int traverse_fn_get_credlist(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DAT
 
        if (strncmp((const char *)kbuf.dptr, "CRED/", 5) == 0) {
 
-               cred = SMB_MALLOC_P(struct cred_list);
+               cred = SMB_CALLOC_ARRAY(struct cred_list, 1);
                if (cred == NULL) {
                        DBG_ERR("traverse_fn_remove_first_creds: failed to malloc new entry for list\n");
                        return -1;
                }
 
-               ZERO_STRUCTP(cred);
-
                /* save a copy of the key */
 
                fstrcpy(cred->name, (const char *)kbuf.dptr);