diff options
Diffstat (limited to 'usb.c')
-rw-r--r-- | usb.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -44,6 +44,7 @@ extern struct pciusb_entries usb_probe(void) { struct pciusb_entries r; struct pciusb_entry *e = NULL; char *vendor_text = NULL, *product_text = NULL; + size_t allocated = MAX_DEVICES; r.nb = 0; names_init("/usr/share/usb.ids"); @@ -63,7 +64,11 @@ extern struct pciusb_entries usb_probe(void) { r.entries = malloc(sizeof(struct pciusb_entry) * MAX_DEVICES); /* for further information on the format parsed by this state machine, * read /usr/share/doc/kernel-doc-X.Y.Z/usb/proc_usb_info.txt */ - for(line = 1; fgets(buf, sizeof(buf) - 1, f) && r.nb < MAX_DEVICES; line++) { + for(line = 1; fgets(buf, sizeof(buf) - 1, f); line++) { + if (r.nb >= allocated) { + allocated = r.nb*2; + r.entries = realloc(r.entries, sizeof(struct pciusb_entry) * allocated); + } switch (buf[0]) { case 'T': { |