Dynamically allocate adb/usb devices using a vector, to avoid a hardcoded limit #3035
+1,106
−115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The maximum number of adb devices (and usb devices for HID/OTG) was hardcoded to 16, which is too low.
The first commit (8d06944) adds a
sc_vector
data structure and API. It is adapted fromvlc_vector
that I initially wrote while implementing the VLC playlist.It is then used for listing usb devices and adb devices to remove any hardcoded limitation (the vector grows dynamically as necessary).
There is still a limitation in the parsing of
adb devices -l
, which is implemented for simplicity in a single pass on the whole output. The output was limited to 4096 bytes (which represents ~40 devices). I changed to 65536 bytes, it should be sufficient in practice (~650 devices listed byadb devices
should never happen).This replaces #3029.
@DarkZeros I added you as co-author for the adb devices listing. Please test this PR and confirm that it works for your use case.