r4236: More *alloc fixes.
authorJeremy Allison <jra@samba.org>
Thu, 16 Dec 2004 21:12:29 +0000 (21:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:53:39 +0000 (10:53 -0500)
Jeremy.

source/auth/pampass.c
source/lib/sysquotas.c
source/smbwrapper/smbw.c
source/smbwrapper/smbw_cache.c
source/torture/cmd_vfs.c

index 68871547b19c03080cc79f9b525ce54ce25a4f29..68c2f183f17f202e9bd3b4b9d7984f94daf2b475 100644 (file)
@@ -59,7 +59,7 @@ typedef int (*smb_pam_conv_fn)(int, const struct pam_message **, struct pam_resp
 /*
  *  Macros to help make life easy
  */
-#define COPY_STRING(s) (s) ? strdup(s) : NULL
+#define COPY_STRING(s) (s) ? SMB_STRDUP(s) : NULL
 
 /*******************************************************************
  PAM error handler.
index 1c5c7e8bd4fbfa6d2c149d03f5913e3caf8039d3..61e2382bc9db2c76e70543df58a01014eafb19a3 100644 (file)
@@ -73,9 +73,9 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
                        continue ;
 
                if (S.st_dev == devno) {
-                       (*mntpath) = strdup(mnt->mnt_dir);
-                       (*bdev) = strdup(mnt->mnt_fsname);
-                       (*fs)   = strdup(mnt->mnt_type);
+                       (*mntpath) = SMB_STRDUP(mnt->mnt_dir);
+                       (*bdev) = SMB_STRDUP(mnt->mnt_fsname);
+                       (*fs)   = SMB_STRDUP(mnt->mnt_type);
                        if ((*mntpath)&&(*bdev)&&(*fs)) {
                                ret = 0;
                        } else {
@@ -124,8 +124,8 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
         * but I don't know how
         * --metze
         */
-       (*mntpath) = strdup(path);
-       (*bdev) = strdup(dev_disk);
+       (*mntpath) = SMB_STRDUP(path);
+       (*bdev) = SMB_STRDUP(dev_disk);
        if ((*mntpath)&&(*bdev)) {
                ret = 0;
        } else {
@@ -152,7 +152,7 @@ static int sys_path_to_bdev(const char *path, char **mntpath, char **bdev, char
        (*bdev) = NULL;
        (*fs) = NULL;
        
-       (*mntpath) = strdup(path);
+       (*mntpath) = SMB_STRDUP(path);
        if (*mntpath) {
                ret = 0;
        } else {
index 0ddacdf8ba5eb940d3f498c7d8cd25fc576a7161..bf60c2bc68c96d4f20d29fcf6c9c3d1e2d5b30e2 100644 (file)
@@ -546,7 +546,7 @@ struct smbw_server *smbw_server(char *server, char *share)
        
        DEBUG(4,(" tconx ok\n"));
 
-       srv = (struct smbw_server *)malloc(sizeof(*srv));
+       srv = SMB_MALLOC_P(struct smbw_server);
        if (!srv) {
                errno = ENOMEM;
                goto failed;
@@ -558,25 +558,25 @@ struct smbw_server *smbw_server(char *server, char *share)
 
        srv->dev = (dev_t)(str_checksum(server) ^ str_checksum(share));
 
-       srv->server_name = strdup(server);
+       srv->server_name = SMB_STRDUP(server);
        if (!srv->server_name) {
                errno = ENOMEM;
                goto failed;
        }
 
-       srv->share_name = strdup(share);
+       srv->share_name = SMB_STRDUP(share);
        if (!srv->share_name) {
                errno = ENOMEM;
                goto failed;
        }
 
-       srv->workgroup = strdup(workgroup);
+       srv->workgroup = SMB_STRDUP(workgroup);
        if (!srv->workgroup) {
                errno = ENOMEM;
                goto failed;
        }
 
-       srv->username = strdup(username);
+       srv->username = SMB_STRDUP(username);
        if (!srv->username) {
                errno = ENOMEM;
                goto failed;
@@ -664,7 +664,7 @@ int smbw_open(const char *fname, int flags, mode_t mode)
                return fd;
        }
 
-       file = (struct smbw_file *)malloc(sizeof(*file));
+       file = SMB_MALLOC_P(struct smbw_file);
        if (!file) {
                errno = ENOMEM;
                goto failed;
@@ -672,7 +672,7 @@ int smbw_open(const char *fname, int flags, mode_t mode)
 
        ZERO_STRUCTP(file);
 
-       file->f = (struct smbw_filedes *)malloc(sizeof(*(file->f)));
+       file->f = SMB_MALLOC_P(struct smbw_filedes);
        if (!file->f) {
                errno = ENOMEM;
                goto failed;
@@ -681,7 +681,7 @@ int smbw_open(const char *fname, int flags, mode_t mode)
        ZERO_STRUCTP(file->f);
 
        file->f->cli_fd = fd;
-       file->f->fname = strdup(path);
+       file->f->fname = SMB_STRDUP(path);
        if (!file->f->fname) {
                errno = ENOMEM;
                goto failed;
@@ -1288,7 +1288,7 @@ int smbw_dup(int fd)
                goto failed;
        }
 
-       file2 = (struct smbw_file *)malloc(sizeof(*file2));
+       file2 = SMB_MALLOC_P(struct smbw_file);
        if (!file2) {
                close(fd2);
                errno = ENOMEM;
@@ -1340,7 +1340,7 @@ int smbw_dup2(int fd, int fd2)
                goto failed;
        }
 
-       file2 = (struct smbw_file *)malloc(sizeof(*file2));
+       file2 = SMB_MALLOC_P(struct smbw_file);
        if (!file2) {
                close(fd2);
                errno = ENOMEM;
index fcb0eda80505d9ed78c2ce7af97b64cd8b3f6722..cfa8ab1f76c35cb659f2db0d970fa7958edbbd2c 100644 (file)
@@ -65,14 +65,14 @@ static void add_cached_names(const char *name, uint32 stype,
        struct name_list **name_list = (struct name_list **)state;
        struct name_list *new_name;
 
-       new_name = (struct name_list *)malloc(sizeof(struct name_list));
+       new_name = SMB_MALLOC_P(struct name_list);
        if (!new_name) return;
 
        ZERO_STRUCTP(new_name);
 
-       new_name->name = strdup(name);
+       new_name->name = SMB_STRDUP(name);
        new_name->stype = stype;
-       new_name->comment = strdup(comment);
+       new_name->comment = SMB_STRDUP(comment);
 
        DLIST_ADD(*name_list, new_name);
 }
@@ -117,8 +117,7 @@ BOOL smbw_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                /* No names cached for this workgroup */
 
                if (names == NULL) {
-                       new_names = (struct cached_names *)
-                               malloc(sizeof(struct cached_names));
+                       new_names = SMB_MALLOC_P(struct cached_names);
 
                        ZERO_STRUCTP(new_names);
                        DLIST_ADD(cached_names, new_names);
@@ -139,7 +138,7 @@ BOOL smbw_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
                                           
                new_names->cache_timeout = now;
                new_names->result = result;
-               new_names->key = strdup(key);
+               new_names->key = SMB_STRDUP(key);
 
                names = new_names;
        }
@@ -173,8 +172,7 @@ int smbw_RNetShareEnum(struct cli_state *cli,
                /* No names cached for this server */
 
                if (names == NULL) {
-                       new_names = (struct cached_names *)
-                               malloc(sizeof(struct cached_names));
+                       new_names = SMB_MALLOC_P(struct cached_names);
 
                        ZERO_STRUCTP(new_names);
                        DLIST_ADD(cached_names, new_names);
@@ -193,7 +191,7 @@ int smbw_RNetShareEnum(struct cli_state *cli,
                                                      &new_names->name_list);
                
                new_names->cache_timeout = now;
-               new_names->key = strdup(key);
+               new_names->key = SMB_STRDUP(key);
 
                names = new_names;
        }
index 43661f1d6cbf3cc2749f38f74cf0378dfc93ecd4..04c40db72e4a6eab2cb828866f94826d427e3d3d 100644 (file)
@@ -285,7 +285,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        }
 
        vfs->files[fd] = (struct files_struct *)malloc(sizeof(struct files_struct));
-       vfs->files[fd]->fsp_name = strdup(argv[1]);
+       vfs->files[fd]->fsp_name = SMB_STRDUP(argv[1]);
        vfs->files[fd]->fd = fd;
        vfs->files[fd]->conn = vfs->conn;
        printf("open: fd=%d\n", fd);