source: lib/data-struct/vector.h

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file was ee6e802, checked in by Shane Alcock <salcock@…>, 5 years ago

Updated copyright blurb on all source files

In some cases, this meant adding copyright blurbs to files that
had never had them before.

  • Property mode set to 100644
File size: 2.3 KB
Line 
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
33typedef void (*vector_data_fn)(void *data);
34typedef 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;
40} libtrace_vector_t;
41
42DLLEXPORT void libtrace_vector_init(libtrace_vector_t *v, size_t element_size);
43DLLEXPORT void libtrace_vector_push_back(libtrace_vector_t *v, void *d);
44DLLEXPORT size_t libtrace_vector_get_size(libtrace_vector_t *v);
45DLLEXPORT int libtrace_vector_get(libtrace_vector_t *v, size_t location, void *d);
46DLLEXPORT void libtrace_vector_append(libtrace_vector_t *dest, libtrace_vector_t *src);
47DLLEXPORT void libtrace_vector_destroy(libtrace_vector_t *v);
48DLLEXPORT void libtrace_zero_vector(libtrace_vector_t *v);
49DLLEXPORT int libtrace_vector_remove_front(libtrace_vector_t *v);
50DLLEXPORT 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
55DLLEXPORT void libtrace_vector_apply_function(libtrace_vector_t *v, vector_data_fn fn);
56
57// Sort the vector using qsort
58DLLEXPORT void libtrace_vector_qsort(libtrace_vector_t *v, int (*compar)(const void *, const void*));
59#endif
Note: See TracBrowser for help on using the repository browser.