WAND Trace processing  4.0.5
vector.h
1 /*
2  *
3  * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand.
4  * All rights reserved.
5  *
6  * This file is part of libtrace.
7  *
8  * This code has been developed by the University of Waikato WAND
9  * research group. For further information please see http://www.wand.net.nz/
10  *
11  * libtrace is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * libtrace is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  *
24  *
25  */
26 #include <pthread.h>
27 /* Need libtrace.h for DLLEXPORT defines */
28 #include "../libtrace.h"
29 
30 #ifndef LIBTRACE_VECTOR_H
31 #define LIBTRACE_VECTOR_H
32 
33 typedef void (*vector_data_fn)(void *data);
34 typedef struct libtrace_vector {
35  size_t max_size;
36  size_t size;
37  size_t element_size;
38  char *elements; // Means we can use array indexing
39  pthread_mutex_t lock;
41 
42 DLLEXPORT void libtrace_vector_init(libtrace_vector_t *v, size_t element_size);
43 DLLEXPORT void libtrace_vector_push_back(libtrace_vector_t *v, void *d);
44 DLLEXPORT size_t libtrace_vector_get_size(libtrace_vector_t *v);
45 DLLEXPORT int libtrace_vector_get(libtrace_vector_t *v, size_t location, void *d);
46 DLLEXPORT void libtrace_vector_append(libtrace_vector_t *dest, libtrace_vector_t *src);
47 DLLEXPORT void libtrace_vector_destroy(libtrace_vector_t *v);
48 DLLEXPORT void libtrace_zero_vector(libtrace_vector_t *v);
49 DLLEXPORT int libtrace_vector_remove_front(libtrace_vector_t *v);
50 DLLEXPORT void libtrace_vector_empty(libtrace_vector_t *v);
51 
52 // For now this is a special case and this doesn't really belong
53 // here, but to do this properly a full lock is required as
54 // multiple items are changed
55 DLLEXPORT void libtrace_vector_apply_function(libtrace_vector_t *v, vector_data_fn fn);
56 
57 // Sort the vector using qsort
58 DLLEXPORT void libtrace_vector_qsort(libtrace_vector_t *v, int (*compar)(const void *, const void*));
59 #endif
Definition: vector.h:34