summaryrefslogtreecommitdiff
path: root/libusb/io.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-02-26 15:55:10 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2020-02-26 15:55:10 -0800
commit281ca64c8ac9b9ee6ec72f2b776016aa98e964ba (patch)
tree896ad067c8c31f24adbf47a00470efe49e0f76cd /libusb/io.c
parent0e8f3997bd7b11390e9ec7b7de7eb31f403c1c83 (diff)
downloadlibusb-281ca64c8ac9b9ee6ec72f2b776016aa98e964ba.tar.gz
core: Introduce accessor functions for structure private data
The backend private data for the internal library structures has been accessed through a zero-length os_priv array of type unsigned char. This approach had two particular disadvantages: 1) A special attribute was needed on the 'os_priv' member to ensure that the field was properly aligned to a natural pointer alignment. The support needed for this is not available in every compiler. 2) Each access to the private data areas required an explicit cast from unsigned char to the type required by the backend. This change reworks the way the private data is accessed by the backends. New accessor functions return the private data as a void pointer type, removing the need for an explicit cast (except for Haiku, which is C++). The special alignment attribute trickery is also replaced by simple pointer arithmetic. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/io.c')
-rw-r--r--libusb/io.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 595409e..a691311 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1275,7 +1275,7 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(
itransfer = (struct usbi_transfer *)(ptr + priv_size);
itransfer->num_iso_packets = iso_packets;
- itransfer->os_priv = ptr;
+ itransfer->priv = ptr;
usbi_mutex_init(&itransfer->lock);
transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
usbi_dbg("transfer %p", transfer);
@@ -1317,7 +1317,7 @@ void API_EXPORTED libusb_free_transfer(struct libusb_transfer *transfer)
priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size);
ptr = (unsigned char *)itransfer - priv_size;
- assert(ptr == itransfer->os_priv);
+ assert(ptr == itransfer->priv);
free(ptr);
}