summaryrefslogtreecommitdiff
path: root/src/common/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/array.c')
-rw-r--r--src/common/array.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/common/array.c b/src/common/array.c
index e4e7bb1..f520d1d 100644
--- a/src/common/array.c
+++ b/src/common/array.c
@@ -157,6 +157,64 @@ void unlock_flat_array(flat_array_t **array)
/******************************************************************************
* *
+* Paramètres : array = tableau compressé à mettre à jour. [OUT] *
+* *
+* Description : Réinitialise un tableau sans traitement excessif. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void reset_flat_array(flat_array_t **array)
+{
+ size_t count; /* Nombre d'éléments présents */
+ ext_flat_array_t *extended; /* Version de tableau étendue */
+
+ assert(FLAT_ARRAY_IS_LOCKED(*array));
+
+ count = count_flat_array_items(*array);
+
+ switch (count)
+ {
+ case 0:
+ break;
+
+ case 1:
+
+ assert(FLAT_ARRAY_HAS_NO_INDEX(*array));
+
+ free(GET_LONELY_ITEM(*array));
+
+ *array = NULL;
+
+ lock_flat_array(array);
+
+ break;
+
+ default:
+
+ assert(!FLAT_ARRAY_HAS_NO_INDEX(*array));
+
+ extended = EXTENDED_ARRAY(*array);
+
+ free(extended->items);
+ free(extended);
+
+ *array = NULL;
+
+ lock_flat_array(array);
+
+ break;
+
+ }
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : array = tableau compressé à consulter. *
* *
* Description : Indique la quantité d'éléments présents dans le tableau. *