util/vma: Add an option to configure high/low preference
[mesa.git] / src / util / u_vector.c
index 4dc7bc22b6939c76af7140d8689d59a956339857..15f8ed6bdad43802220debf6582878db4516fdc1 100644 (file)
 #include "util/u_math.h"
 #include "util/u_vector.h"
 
+/** @file u_vector.c
+ *
+ * A dynamically growable, circular buffer.  Elements are added at head and
+ * removed from tail. head and tail are free-running uint32_t indices and we
+ * only compute the modulo with size when accessing the array.  This way,
+ * number of bytes in the queue is always head - tail, even in case of
+ * wraparound.
+ */
+
 int
 u_vector_init(struct u_vector *vector, uint32_t element_size, uint32_t size)
 {
-   assert(util_is_power_of_two(size));
-   assert(element_size < size && util_is_power_of_two(element_size));
+   assert(util_is_power_of_two_nonzero(size));
+   assert(element_size < size && util_is_power_of_two_nonzero(element_size));
 
    vector->head = 0;
    vector->tail = 0;