diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-01-06 03:06:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:08:25 -0500 |
commit | ddc10d4d37984246a6547e34a32d629c689c40d1 (patch) | |
tree | bba9f8756de8fe38a6926edd0802aeff25abe0cf /source4/ntvfs | |
parent | 0b54d9236fad72527ed1bcf4236767a09090d304 (diff) | |
download | samba-ddc10d4d37984246a6547e34a32d629c689c40d1.tar.gz samba-ddc10d4d37984246a6547e34a32d629c689c40d1.tar.bz2 samba-ddc10d4d37984246a6547e34a32d629c689c40d1.zip |
r4549: got rid of a lot more uses of plain talloc(), instead using
talloc_size() or talloc_array_p() where appropriate.
also fixed a memory leak in pvfs_copy_file() (failed to free a memory
context)
(This used to be commit 89b74b53546e1570b11b3702f40bee58aed8c503)
Diffstat (limited to 'source4/ntvfs')
-rw-r--r-- | source4/ntvfs/ntvfs_generic.c | 11 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_rename.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_resolve.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_util.c | 3 |
4 files changed, 11 insertions, 7 deletions
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 407bd38f74..051e92b19c 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -713,8 +713,10 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_STREAM_INFORMATION: info->stream_info.out.num_streams = info2->generic.out.num_streams; if (info->stream_info.out.num_streams > 0) { - info->stream_info.out.streams = talloc(req, - info->stream_info.out.num_streams * sizeof(struct stream_struct)); + info->stream_info.out.streams = + talloc_array_p(req, + struct stream_struct, + info->stream_info.out.num_streams); if (!info->stream_info.out.streams) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d streams\n", info->stream_info.out.num_streams)); @@ -751,8 +753,9 @@ NTSTATUS ntvfs_map_fileinfo(struct smbsrv_request *req, union smb_fileinfo *info case RAW_FILEINFO_ALL_EAS: info->all_eas.out.num_eas = info2->generic.out.num_eas; if (info->all_eas.out.num_eas > 0) { - info->all_eas.out.eas = talloc(req, - info->all_eas.out.num_eas * sizeof(struct ea_struct)); + info->all_eas.out.eas = talloc_array_p(req, + struct ea_struct, + info->all_eas.out.num_eas); if (!info->all_eas.out.eas) { DEBUG(2,("ntvfs_map_fileinfo: no memory for %d eas\n", info->all_eas.out.num_eas)); diff --git a/source4/ntvfs/posix/pvfs_rename.c b/source4/ntvfs/posix/pvfs_rename.c index 8e057f214b..3203f7fa86 100644 --- a/source4/ntvfs/posix/pvfs_rename.c +++ b/source4/ntvfs/posix/pvfs_rename.c @@ -35,7 +35,7 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx, char *dest, *d; /* the length is bounded by the length of the two strings combined */ - dest = talloc(mem_ctx, strlen(fname) + strlen(pattern) + 1); + dest = talloc_size(mem_ctx, strlen(fname) + strlen(pattern) + 1); if (dest == NULL) { return NULL; } diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index 4ad3476795..fc1576b955 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -412,7 +412,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx, const char **fname, uint_t } /* rebuild the name */ - ret = talloc(mem_ctx, len+1); + ret = talloc_size(mem_ctx, len+1); if (ret == NULL) { talloc_free(s); return NT_STATUS_NO_MEMORY; diff --git a/source4/ntvfs/posix/pvfs_util.c b/source4/ntvfs/posix/pvfs_util.c index 6026b9fbf3..eb0f04728c 100644 --- a/source4/ntvfs/posix/pvfs_util.c +++ b/source4/ntvfs/posix/pvfs_util.c @@ -89,7 +89,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs, mode_t mode; NTSTATUS status; size_t buf_size = 0x10000; - char *buf = talloc(name2, buf_size); + char *buf = talloc_size(name2, buf_size); if (buf == NULL) { return NT_STATUS_NO_MEMORY; @@ -134,6 +134,7 @@ NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs, } } + talloc_free(buf); close(fd1); mode = pvfs_fileperms(pvfs, name1->dos.attrib); |