su  1.12.11devel
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
26 
27 #define SU_VECTOR_H
28 
37 #ifndef SU_ALLOC_H
38 #include <sofia-sip/su_alloc.h>
39 #endif
40 
41 SOFIA_BEGIN_DECLS
42 
43 typedef struct su_vector_s su_vector_t;
44 typedef void (* su_free_func_t) (void *data);
45 
47 SU_DLL su_vector_t *su_vector_create(su_home_t *home, su_free_func_t free_f)
48  __attribute__((__malloc__));
49 
51 SU_DLL void su_vector_destroy(su_vector_t *);
52 
54 SU_DLL int su_vector_insert(su_vector_t *vector, usize_t index, void *item);
55 
56 SU_DLL int su_vector_remove(su_vector_t *vector, usize_t index);
57 
59 SU_DLL int su_vector_append(su_vector_t *, void *item);
60 
62 SU_DLL void *su_vector_item(su_vector_t const *, usize_t i);
63 
65 SU_DLL usize_t su_vector_len(su_vector_t const *l);
66 
67 SU_DLL int su_vector_empty(su_vector_t *vector);
68 SU_DLL int su_vector_is_empty(su_vector_t const *vector);
69 
70 #if SU_HAVE_INLINE
72 su_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 
81 SU_DLL void **su_vector_get_array(su_vector_t *)
82  __attribute__((__malloc__));
83 
85 SU_DLL void su_vector_free_array(su_vector_t *, void *array[]);
86 
87 SOFIA_END_DECLS
88 
89 #endif /* !defined SU_VECTOR_H */
su_home_t
SU_HOME_T su_home_t
Memory home type.
Definition: su_alloc.h:50
su_alloc.h
Home-based memory management interface.
su_vector_item
void * su_vector_item(su_vector_t const *, usize_t i)
Get a numbered item from vector.
Definition: su_vector.c:264
su_vector_insert
int su_vector_insert(su_vector_t *vector, usize_t index, void *item)
Insert an item to vector.
Definition: su_vector.c:162
su_vector_empty
int su_vector_empty(su_vector_t *vector)
Remove all items from vector.
Definition: su_vector.c:209
su_inline
#define su_inline
Define as suitable declarator static inline functions.
Definition: su_configure.h:90
su_vector_remove
int su_vector_remove(su_vector_t *vector, usize_t index)
Remove an item from vector.
Definition: su_vector.c:184
su_vector_destroy
void su_vector_destroy(su_vector_t *)
Destroy a vector.
Definition: su_vector.c:95
su_vector_get_array
void ** su_vector_get_array(su_vector_t *))
Get an array of pointers from the vector.
Definition: su_vector.c:298
array
Description of array.
Definition: foo.c:52
su_vector_len
usize_t su_vector_len(su_vector_t const *l)
Get number of items in vector.
Definition: su_vector.c:277
su_vector_append
int su_vector_append(su_vector_t *, void *item)
Append a item to vector.
Definition: su_vector.c:237
su_vector_create
su_vector_t * su_vector_create(su_home_t *home, su_free_func_t free_f))
Create a vector.
Definition: su_vector.c:76
su_vector_free_array
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.