Provide a helper function that allows to reset an existing bulk object.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
*/
struct gpiod_line_bulk *gpiod_line_bulk_new(unsigned int max_lines) GPIOD_API;
+/**
+ * @brief Reset a bulk object. Remove all lines and set size to 0.
+ * @param bulk Bulk object to reset.
+ */
+void gpiod_line_bulk_reset(struct gpiod_line_bulk *bulk) GPIOD_API;
+
/**
* @brief Release all resources allocated for this bulk object.
* @param bulk Bulk object to free.
if (!bulk)
return NULL;
- memset(bulk, 0, size);
bulk->max_lines = max_lines;
+ gpiod_line_bulk_reset(bulk);
return bulk;
}
+void gpiod_line_bulk_reset(struct gpiod_line_bulk *bulk)
+{
+ bulk->num_lines = 0;
+ memset(bulk->lines, 0, bulk->max_lines * sizeof(struct line *));
+}
+
void gpiod_line_bulk_free(struct gpiod_line_bulk *bulk)
{
free(bulk);