Small documentation update
[libftdi] / src / ftdi.c
index b7876fa..096a03d 100644 (file)
@@ -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.