diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2017-05-07 21:13:00 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2017-05-07 21:13:00 (GMT) | 
| commit | 13be5aa2ac44f7bfc70ee25e7ba20ae2adf58ad5 (patch) | |
| tree | ff0ac2eb2b4be1774329603ccd3c6bc307789237 /src/common/array.c | |
| parent | 11e76cece91707f1910d3b1fa56464e261757a52 (diff) | |
Made the preloading process work as intended.
Diffstat (limited to 'src/common/array.c')
| -rw-r--r-- | src/common/array.c | 58 | 
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.     *  | 
