On 24-01-23, 10:58, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > We have two functions in the C API that allow users to retrieve a list > of offsets from objects: gpiod_line_request_get_offsets() and > gpiod_line_config_get_offsets(). Even though they serve pretty much the > same purpose, they have different signatures and one of them also > requires the user to free the memory allocated within the libgpiod > library with a non-libgpiod free() function. > > Unify them: make them take the array in which to store offsets and the > size of this array. Make them return the number of offsets actually > stored in the array and make them impossible to fail. Change their names > to be more descriptive and in the case of line_config: add a new function > that allows users to get the number of configured offsets. > > Update the entire tree to use the new interfaces. > > For rust bindings: also unify the line config interface to return a map > of line settings like C++ bindings do instead of having a function to > get settings by offset. A map returned from a single call is easier to > iterate over with a for loop than using an integer and calling the > previous line_settings() method. > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > --- > v2 -> v3: > - use a custom type for the offset -> Settings mapping (defined as an > IntMap<line::Settings>) > - add missing '// SAFETY' comments > - apply cargo fmt > > v3 -> v4: > - apply missing cargo fmt hints (by using rustfmt) Acked-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx> -- viresh