summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2015-06-13 23:50:35 +0200
committerChris Dickens <christopher.a.dickens@gmail.com>2015-07-28 23:39:23 -0700
commitf9480d05029f92cade0cb481117a58d80d0364d5 (patch)
tree60be7e16ec251893a26dd52079800f423bb38c85
parentd473d0b2e642abe2a9219011f8684d9eb9736ec1 (diff)
downloadlibusb-f9480d05029f92cade0cb481117a58d80d0364d5.tar.gz
linux_usbfs: use calloc for multiplication
calloc can do n, elemsize multiplication itself * Closes #74 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r--libusb/os/linux_usbfs.c7
-rw-r--r--libusb/version_nano.h2
2 files changed, 3 insertions, 6 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 86ad1f2..9d9d00e 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -1767,7 +1767,6 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
int bulk_buffer_len, use_bulk_continuation;
int r;
int i;
- size_t alloc_size;
if (is_out && (transfer->flags & LIBUSB_TRANSFER_ADD_ZERO_PACKET) &&
!(dpriv->caps & USBFS_CAP_ZERO_PACKET))
@@ -1826,8 +1825,7 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer)
}
usbi_dbg("need %d urbs for new transfer with length %d", num_urbs,
transfer->length);
- alloc_size = num_urbs * sizeof(struct usbfs_urb);
- urbs = calloc(1, alloc_size);
+ urbs = calloc(num_urbs, sizeof(struct usbfs_urb));
if (!urbs)
return LIBUSB_ERROR_NO_MEM;
tpriv->urbs = urbs;
@@ -1969,8 +1967,7 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer)
}
usbi_dbg("need %d %dk URBs for transfer", num_urbs, MAX_ISO_BUFFER_LENGTH / 1024);
- alloc_size = num_urbs * sizeof(*urbs);
- urbs = calloc(1, alloc_size);
+ urbs = calloc(num_urbs, sizeof(*urbs));
if (!urbs)
return LIBUSB_ERROR_NO_MEM;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 97cf890..f865dc3 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10989
+#define LIBUSB_NANO 10990