Add a new ply_array_contains_uint32_element which checks if the queried
ply-array contains an element with the passed in uint32_t value.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
return data;
}
+bool
+ply_array_contains_uint32_element (ply_array_t *array, const uint32_t element)
+{
+ uint32_t const *elements;
+ int i, size;
+
+ assert (array->element_type == PLY_ARRAY_ELEMENT_TYPE_UINT32);
+
+ elements = (uint32_t const *) ply_buffer_get_bytes (array->buffer);
+ size = (ply_buffer_get_size (array->buffer) / sizeof(const uint32_t)) - 1;
+
+ for (i = 0; i < size; i++)
+ if (elements[i] == element)
+ return true;
+
+ return false;
+}
+
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
#define PLY_ARRAY_H
#include <stdint.h>
+#include <stdbool.h>
typedef struct _ply_array ply_array_t;
typedef enum _ply_array_element_type ply_array_element_type_t;
void **ply_array_steal_pointer_elements (ply_array_t *array);
uint32_t *ply_array_steal_uint32_elements (ply_array_t *array);
+bool ply_array_contains_uint32_element (ply_array_t *array,
+ const uint32_t element);
#endif
#endif /* PLY_ARRAY_H */