calloc(3) takes `nelem` (or `nmemb` in glibc) first, and then size of
elements. No difference expected for having these in reverse order,
however should follow the standard.
http://pubs.opengroup.org/onlinepubs/
009695399/functions/calloc.html
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
Closes #7405
memset(dki_info, 0, sizeof (*dki_info));
- path = calloc(PATH_MAX, 1);
+ path = calloc(1, PATH_MAX);
if (path == NULL)
goto error;
length = sizeof (struct dk_gpt) +
sizeof (struct dk_part) * (nparts - 1);
- if ((*vtoc = calloc(length, 1)) == NULL)
+ if ((*vtoc = calloc(1, length)) == NULL)
return (-1);
vptr = *vtoc;
nparts = EFI_MIN_ARRAY_SIZE / sizeof (efi_gpe_t);
length = (int) sizeof (struct dk_gpt) +
(int) sizeof (struct dk_part) * (nparts - 1);
- if ((*vtoc = calloc(length, 1)) == NULL)
+ if ((*vtoc = calloc(1, length)) == NULL)
return (VT_ERROR);
(*vtoc)->efi_nparts = nparts;
{
sa_fstype_t *fstype;
- fstype = calloc(sizeof (sa_fstype_t), 1);
+ fstype = calloc(1, sizeof (sa_fstype_t));
if (fstype == NULL)
return (NULL);
{
sa_handle_impl_t impl_handle;
- impl_handle = calloc(sizeof (struct sa_handle_impl), 1);
+ impl_handle = calloc(1, sizeof (struct sa_handle_impl));
if (impl_handle == NULL)
return (NULL);
{
sa_share_impl_t impl_share;
- impl_share = calloc(sizeof (struct sa_share_impl), 1);
+ impl_share = calloc(1, sizeof (struct sa_share_impl));
if (impl_share == NULL)
return (NULL);
return (NULL);
}
- impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count);
+ impl_share->fsinfo = calloc(fstypes_count, sizeof (sa_share_fsinfo_t));
if (impl_share->fsinfo == NULL) {
free(impl_share->sharepath);
mbPathlen = strlen(mbPath);
- if ((wcPath = calloc(sizeof (wchar_t), mbPathlen+1)) == NULL) {
+ if ((wcPath = calloc(mbPathlen+1, sizeof (wchar_t))) == NULL) {
free(mbPath);
return (NULL);
}
{
zfs_cmd_t zc = {"\0"};
- zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+ zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
if (zhp == NULL)
return (NULL);
zfs_handle_t *
make_dataset_handle_zc(libzfs_handle_t *hdl, zfs_cmd_t *zc)
{
- zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+ zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
if (zhp == NULL)
return (NULL);
zfs_handle_t *
make_dataset_simple_handle_zc(zfs_handle_t *pzhp, zfs_cmd_t *zc)
{
- zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+ zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
if (zhp == NULL)
return (NULL);
zfs_handle_t *
zfs_handle_dup(zfs_handle_t *zhp_orig)
{
- zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+ zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
if (zhp == NULL)
return (NULL);
make_bookmark_handle(zfs_handle_t *parent, const char *path,
nvlist_t *bmark_props)
{
- zfs_handle_t *zhp = calloc(sizeof (zfs_handle_t), 1);
+ zfs_handle_t *zhp = calloc(1, sizeof (zfs_handle_t));
if (zhp == NULL)
return (NULL);
return (0);
size = P2ALIGN_TYPED(statbuf.st_size, sizeof (vdev_label_t), uint64_t);
- if ((label = calloc(sizeof (vdev_label_t), 1)) == NULL)
+ if ((label = calloc(1, sizeof (vdev_label_t))) == NULL)
return (-1);
for (l = 0; l < VDEV_LABELS; l++) {
if (buf)
free(buf);
bufsz = (size_t)st.st_blksize;
- buf = calloc(bufsz, 1);
+ buf = calloc(1, bufsz);
if (buf == NULL) {
(void) fprintf(stderr, gettext(
"Could not allocate buffer of"