su 1.12.11devel
Loading...
Searching...
No Matches
su_vector.h
Go to the documentation of this file.
1/*
2 * This file is part of the Sofia-SIP package
3 *
4 * Copyright (C) 2005 Nokia Corporation.
5 *
6 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef SU_VECTOR_H
27#define SU_VECTOR_H
28
37#ifndef SU_ALLOC_H
38#include <sofia-sip/su_alloc.h>
39#endif
40
41SOFIA_BEGIN_DECLS
42
43typedef struct su_vector_s su_vector_t;
44typedef void (* su_free_func_t) (void *data);
45
47SU_DLL su_vector_t *su_vector_create(su_home_t *home, su_free_func_t free_f)
48 __attribute__((__malloc__));
49
51SU_DLL void su_vector_destroy(su_vector_t *);
52
54SU_DLL int su_vector_insert(su_vector_t *vector, usize_t index, void *item);
55
56SU_DLL int su_vector_remove(su_vector_t *vector, usize_t index);
57
59SU_DLL int su_vector_append(su_vector_t *, void *item);
60
62SU_DLL void *su_vector_item(su_vector_t const *, usize_t i);
63
65SU_DLL usize_t su_vector_len(su_vector_t const *l);
66
67SU_DLL int su_vector_empty(su_vector_t *vector);
68SU_DLL int su_vector_is_empty(su_vector_t const *vector);
69
70#if SU_HAVE_INLINE
72su_home_t *su_vector_home(su_vector_t *s)
73{
74 return (su_home_t *)s;
75}
76#else
77#define su_vector_home(s) ((su_home_t *)(s))
78#endif
79
81SU_DLL void **su_vector_get_array(su_vector_t *)
82 __attribute__((__malloc__));
83
85SU_DLL void su_vector_free_array(su_vector_t *, void *array[]);
86
87SOFIA_END_DECLS
88
89#endif /* !defined SU_VECTOR_H */
Description of array.
Definition foo.c:52
Home-based memory management interface.
SU_HOME_T su_home_t
Memory home type.
Definition su_alloc.h:50
#define su_inline
Define as suitable declarator static inline functions.
Definition su_configure.h:90
void ** su_vector_get_array(su_vector_t *))
Get an array of pointers from the vector.
Definition su_vector.c:298
int su_vector_append(su_vector_t *, void *item)
Append a item to vector.
Definition su_vector.c:237
su_vector_t * su_vector_create(su_home_t *home, su_free_func_t free_f))
Create a vector.
Definition su_vector.c:76
int su_vector_empty(su_vector_t *vector)
Remove all items from vector.
Definition su_vector.c:209
void * su_vector_item(su_vector_t const *, usize_t i)
Get a numbered item from vector.
Definition su_vector.c:264
int su_vector_remove(su_vector_t *vector, usize_t index)
Remove an item from vector.
Definition su_vector.c:184
int su_vector_insert(su_vector_t *vector, usize_t index, void *item)
Insert an item to vector.
Definition su_vector.c:162
usize_t su_vector_len(su_vector_t const *l)
Get number of items in vector.
Definition su_vector.c:277
void su_vector_destroy(su_vector_t *)
Destroy a vector.
Definition su_vector.c:95
void su_vector_free_array(su_vector_t *, void *array[])
Free the array.

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.