Changeset 96ec0a9 in mainline


Ignore:
Timestamp:
2011-10-29T21:13:56Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d9cd62
Parents:
e27c2476
Message:

libusbdev: Add function do properly destroy alternative interfaces.

Location:
uspace/lib/usbdev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/driver.h

    re27c2476 r96ec0a9  
    174174    usb_device_t **, const char **);
    175175void usb_device_deinit(usb_device_t *);
     176
    176177void * usb_device_data_alloc(usb_device_t *, size_t);
    177178
     
    179180int usb_alternate_interfaces_create(const uint8_t *, size_t, int,
    180181    usb_alternate_interfaces_t **);
    181 
     182void usb_alternate_interfaces_destroy(usb_alternate_interfaces_t *);
    182183#endif
    183184/**
  • uspace/lib/usbdev/src/altiface.c

    re27c2476 r96ec0a9  
    9898        assert(config_descr_size > 0);
    9999
     100        alternates_ptr = NULL;
    100101        if (interface_number < 0) {
    101                 alternates_ptr = NULL;
    102102                return EOK;
    103103        }
     
    105105        usb_alternate_interfaces_t *alternates
    106106            = malloc(sizeof(usb_alternate_interfaces_t));
    107 
    108107        if (alternates == NULL) {
    109108                return ENOMEM;
     
    119118        }
    120119
    121         alternates->alternatives = malloc(alternates->alternative_count
    122             * sizeof(usb_alternate_interface_descriptors_t));
     120        alternates->alternatives = calloc(alternates->alternative_count,
     121            sizeof(usb_alternate_interface_descriptors_t));
    123122        if (alternates->alternatives == NULL) {
    124123                free(alternates);
     
    176175}
    177176
    178 
     177void usb_alternate_interfaces_destroy(usb_alternate_interfaces_t *alternate)
     178{
     179        if (!alternate)
     180                return;
     181        free(alternate->alternatives);
     182        free(alternate);
     183}
    179184/**
    180185 * @}
Note: See TracChangeset for help on using the changeset viewer.