X-Git-Url: http://developer.intra2net.com/git/?a=blobdiff_plain;f=src%2Fftdi.c;h=096a03d50a0acf928c56b9ad51cd2527d05e27a2;hb=d77b0e94a0a6c7cbd09ecb5bd768bcb525befa21;hp=b7876fab0e440fef6946c0f7a2cc0744b6b024fa;hpb=474786c0caf97e4b573e7a785ce0421ed79769d3;p=libftdi diff --git a/src/ftdi.c b/src/ftdi.c index b7876fa..096a03d 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -158,6 +158,7 @@ int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devli ftdi_error_return(-2, "usb_find_devices() failed"); curdev = devlist; + *curdev = NULL; for (bus = usb_busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { if (dev->descriptor.idVendor == vendor @@ -186,13 +187,15 @@ int ftdi_usb_find_all(struct ftdi_context *ftdi, struct ftdi_device_list **devli */ void ftdi_list_free(struct ftdi_device_list **devlist) { - struct ftdi_device_list **curdev; - for (; *devlist == NULL; devlist = curdev) { - curdev = &(*devlist)->next; - free(*devlist); + struct ftdi_device_list *curdev, *next; + + for (curdev = *devlist; curdev != NULL;) { + next = curdev->next; + free(curdev); + curdev = next; } - devlist = NULL; + *devlist = NULL; } /** @@ -201,6 +204,9 @@ void ftdi_list_free(struct ftdi_device_list **devlist) The parameters manufacturer, description and serial may be NULL or pointer to buffers to store the fetched strings. + \note Use this function only in combination with ftdi_usb_find_all() + as it closes the internal "usb_dev" after use. + \param ftdi pointer to ftdi_context \param dev libusb usb_dev to use \param manufacturer Store manufacturer string here if not NULL @@ -735,6 +741,7 @@ int ftdi_write_data_get_chunksize(struct ftdi_context *ftdi, unsigned int *chunk \param size Size of the buffer \retval <0: error code from usb_bulk_read() + \retval 0: no data was available \retval >0: number of bytes read \remark This function is not useful in bitbang mode.