Display and control your Android device
Rename "hole" to "uninitialized" in vector APIs
Romain Vimont740460d04ea7
diff --git a/app/src/delay_buffer.c b/app/src/delay_buffer.cindex a46f43b2..aa73585e 100644--- a/app/src/delay_buffer.c+++ b/app/src/delay_buffer.c@@ -218,7 +218,8 @@ sc_delay_buffer_frame_sink_push(struct sc_frame_sink *sink,return sc_frame_source_sinks_push(&db->frame_source, frame);}- struct sc_delayed_packet *dpacket = sc_vecdeque_push_hole(&db->queue);+ struct sc_delayed_packet *dpacket =+ sc_vecdeque_push_uninitialized(&db->queue);if (!dpacket) {sc_mutex_unlock(&db->mutex);LOG_OOM();@@ -255,7 +256,8 @@ sc_delay_buffer_frame_sink_push_session(struct sc_frame_sink *sink,return false;}- struct sc_delayed_packet *dpacket = sc_vecdeque_push_hole(&db->queue);+ struct sc_delayed_packet *dpacket =+ sc_vecdeque_push_uninitialized(&db->queue);if (!dpacket) {sc_mutex_unlock(&db->mutex);LOG_OOM();diff --git a/app/src/usb/aoa_hid.c b/app/src/usb/aoa_hid.cindex 8cb62bfd..189e9b08 100644--- a/app/src/usb/aoa_hid.c+++ b/app/src/usb/aoa_hid.c@@ -238,7 +238,7 @@ sc_aoa_push_input_with_ack_to_wait(struct sc_aoa *aoa,bool was_empty = sc_vecdeque_is_empty(&aoa->queue);struct sc_aoa_event *aoa_event =- sc_vecdeque_push_hole_noresize(&aoa->queue);+ sc_vecdeque_push_uninitialized_noresize(&aoa->queue);aoa_event->type = SC_AOA_EVENT_TYPE_INPUT;aoa_event->input.hid = *hid_input;aoa_event->input.ack_to_wait = ack_to_wait;@@ -267,7 +267,8 @@ sc_aoa_push_open(struct sc_aoa *aoa, const struct sc_hid_open *hid_open,// an OPEN event is non-droppable, so push it to the queue even above the// SC_AOA_EVENT_QUEUE_LIMIT- struct sc_aoa_event *aoa_event = sc_vecdeque_push_hole(&aoa->queue);+ struct sc_aoa_event *aoa_event =+ sc_vecdeque_push_uninitialized(&aoa->queue);if (!aoa_event) {LOG_OOM();sc_mutex_unlock(&aoa->mutex);@@ -298,7 +299,8 @@ sc_aoa_push_close(struct sc_aoa *aoa, const struct sc_hid_close *hid_close) {// a CLOSE event is non-droppable, so push it to the queue even above the// SC_AOA_EVENT_QUEUE_LIMIT- struct sc_aoa_event *aoa_event = sc_vecdeque_push_hole(&aoa->queue);+ struct sc_aoa_event *aoa_event =+ sc_vecdeque_push_uninitialized(&aoa->queue);if (!aoa_event) {LOG_OOM();sc_mutex_unlock(&aoa->mutex);diff --git a/app/src/util/vecdeque.h b/app/src/util/vecdeque.hindex 6f34a4ef..439903a8 100644--- a/app/src/util/vecdeque.h+++ b/app/src/util/vecdeque.h@@ -302,7 +302,7 @@ sc_vecdeque_growsize_(size_t value)* This function may not fail. It returns a valid non-NULL pointer to the* uninitialized item just pushed.*/-#define sc_vecdeque_push_hole_noresize(pv) \+#define sc_vecdeque_push_uninitialized_noresize(pv) \({ \assert(!sc_vecdeque_is_full(pv)); \++(pv)->size; \@@ -317,9 +317,9 @@ sc_vecdeque_growsize_(size_t value)* This function returns either a valid non-NULL pointer to the uninitialized* item just pushed, or NULL on reallocation failure.*/-#define sc_vecdeque_push_hole(pv) \+#define sc_vecdeque_push_uninitialized(pv) \(sc_vecdeque_grow_if_needed_(pv) ? \- sc_vecdeque_push_hole_noresize(pv) : NULL)+ sc_vecdeque_push_uninitialized_noresize(pv) : NULL)/*** Push an itemdiff --git a/app/src/util/vector.h b/app/src/util/vector.hindex 5b399d56..7e57f4bb 100644--- a/app/src/util/vector.h+++ b/app/src/util/vector.h@@ -259,21 +259,21 @@ sc_vector_growsize_(size_t value)})/**- * Insert an hole of size `count` to the given index+ * Insert `count` uninitialized items at the given index*- * The items in range [index; size-1] will be moved. The items in the hole are+ * The items in range [index; size-1] will be moved. The items in the gap are* left uninitialized.** \param pv a pointer to the vector- * \param index the index where the hole is to be inserted- * \param count the number of items in the hole+ * \param index the index where the uninitialized items are to be inserted+ * \param count the number of items in the gap* \retval true if no allocation failed* \retval false on allocation failure (the vector is left untouched)*/-#define sc_vector_insert_hole(pv, index, count) \- sc_vector_insert_hole_(pv, (size_t) index, (size_t) count);+#define sc_vector_insert_uninitialized(pv, index, count) \+ sc_vector_insert_uninitialized_(pv, (size_t) index, (size_t) count);-#define sc_vector_insert_hole_(pv, index, count) \+#define sc_vector_insert_uninitialized_(pv, index, count) \({ \bool ok = sc_vector_reserve(pv, (pv)->size + (count)); \if (ok) { \@@ -303,7 +303,7 @@ sc_vector_growsize_(size_t value)#define sc_vector_insert_(pv, index, item) \({ \- bool ok = sc_vector_insert_hole_(pv, index, 1); \+ bool ok = sc_vector_insert_uninitialized_(pv, index, 1); \if (ok) { \(pv)->data[index] = (item); \} \@@ -328,7 +328,7 @@ sc_vector_growsize_(size_t value)#define sc_vector_insert_all_(pv, index, items, count) \({ \sc_vector_check_same_ptr_type_((pv)->data, items); \- bool ok = sc_vector_insert_hole_(pv, index, count); \+ bool ok = sc_vector_insert_uninitialized_(pv, index, count); \if (ok) { \memcpy(&(pv)->data[index], items, count * sizeof(*(pv)->data)); \} \diff --git a/app/tests/test_vecdeque.c b/app/tests/test_vecdeque.cindex 44d33560..b8cfdefe 100644--- a/app/tests/test_vecdeque.c+++ b/app/tests/test_vecdeque.c@@ -142,7 +142,7 @@ static void test_vecdeque_grow(void) {sc_vecdeque_destroy(&vdq);}-static void test_vecdeque_push_hole(void) {+static void test_vecdeque_push_uninitialized(void) {struct SC_VECDEQUE(int) vdq = SC_VECDEQUE_INITIALIZER;bool ok = sc_vecdeque_reserve(&vdq, 20);@@ -152,7 +152,7 @@ static void test_vecdeque_push_hole(void) {assert(sc_vecdeque_size(&vdq) == 0);for (int i = 0; i < 20; ++i) {- int *p = sc_vecdeque_push_hole(&vdq);+ int *p = sc_vecdeque_push_uninitialized(&vdq);assert(p);*p = i * 10;}@@ -167,7 +167,7 @@ static void test_vecdeque_push_hole(void) {assert(sc_vecdeque_size(&vdq) == 10);for (int i = 20; i < 30; ++i) {- int *p = sc_vecdeque_push_hole(&vdq);+ int *p = sc_vecdeque_push_uninitialized(&vdq);assert(p);*p = i * 10;}@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {test_vecdeque_push_pop();test_vecdeque_reserve();test_vecdeque_grow();- test_vecdeque_push_hole();+ test_vecdeque_push_uninitialized();return 0;}