summaryrefslogtreecommitdiff
path: root/src/common/array.h
blob: 2dd5b9f711b9e0d33689d25dc84ff95cbb9caa8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

/* Chrysalide - Outil d'analyse de fichiers binaires
 * array.h - prototypes pour la manipulation optimisée de tableaux au niveau de l'empreinte mémoire
 *
 * Copyright (C) 2017 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  Chrysalide is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Chrysalide is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _COMMON_ARRAY_H
#define _COMMON_ARRAY_H


#include <stdlib.h>
#include <sys/types.h>



/* Type déclaratif de tableau compressé, à 0 ou 1 élément */
typedef void *flat_array_t;


/* Verrouille l'accès à un tableau compressé. */
void lock_flat_array(flat_array_t **);

/* Déverrouille l'accès à un tableau compressé. */
void unlock_flat_array(flat_array_t **);

/* Indique la quantité d'éléments présents dans le tableau. */
size_t count_flat_array_items(const flat_array_t *);

/* Ajoute un élément supplémentaire à un tableau. */
void add_item_to_flat_array(flat_array_t **, const void *, size_t);

/* Ajoute un élément supplémentaire à un tableau trié. */
void insert_item_into_flat_array(flat_array_t **, void *, size_t, __compar_fn_t);

/* Remplace un élément d'un tableau compressé par un autre. */
void rpl_item_in_flat_array(flat_array_t *, size_t, void *, size_t);

/* Retire un élément existant d'un tableau. */
void rem_item_from_flat_array(flat_array_t **, size_t, size_t);

/* Fournit un élément présent dans un tableau compressé. */
void *get_flat_array_item(flat_array_t *, size_t, size_t);



#endif  /* _COMMON_ARRAY_H */