Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_array.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, Emulex
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */
32 
33 /**
34  * @file
35  *
36  */
37 
38 #ifndef __OCS_ARRAY_H__
39 #define __OCS_ARRAY_H__
40 
41 typedef struct ocs_array_s ocs_array_t;
42 
43 extern void ocs_array_set_slablen(uint32_t len);
44 extern ocs_array_t *ocs_array_alloc(ocs_os_handle_t os, uint32_t size, uint32_t count);
45 extern void ocs_array_free(ocs_array_t *array);
46 extern void *ocs_array_get(ocs_array_t *array, uint32_t idx);
47 extern uint32_t ocs_array_get_count(ocs_array_t *array);
48 extern uint32_t ocs_array_get_size(ocs_array_t *array);
49 
50 /* Void pointer array and iterator */
51 typedef struct ocs_varray_s ocs_varray_t;
52 
53 extern ocs_varray_t *ocs_varray_alloc(ocs_os_handle_t os, uint32_t entry_count);
54 extern void ocs_varray_free(ocs_varray_t *ai);
55 extern int32_t ocs_varray_add(ocs_varray_t *ai, void *entry);
56 extern void ocs_varray_iter_reset(ocs_varray_t *ai);
57 extern void *ocs_varray_iter_next(ocs_varray_t *ai);
58 extern void *_ocs_varray_iter_next(ocs_varray_t *ai);
59 extern void ocs_varray_lock(ocs_varray_t *ai);
60 extern void ocs_varray_unlock(ocs_varray_t *ai);
61 extern uint32_t ocs_varray_get_count(ocs_varray_t *ai);
62 
63 #endif /* __OCS_ARRAY_H__ */
ocs_os_handle_t os
Definition: ocs_array.c:219
Void pointer array structure.
Definition: ocs_array.c:218
void * _ocs_varray_iter_next(ocs_varray_t *va)
Return next entry from a void pointer array.
Definition: ocs_array.c:357
uint32_t count
Definition: ocs_array.c:47
uint32_t ocs_array_get_size(ocs_array_t *array)
Return size of array elements in bytes.
Definition: ocs_array.c:203
void ocs_varray_iter_reset(ocs_varray_t *va)
Reset the void pointer array iterator.
Definition: ocs_array.c:314
void ocs_varray_unlock(ocs_varray_t *va)
Release void pointer array lock.
Definition: ocs_array.c:393
void ocs_varray_lock(ocs_varray_t *va)
Take void pointer array lock.
Definition: ocs_array.c:378
ocs_array_t * ocs_array_alloc(ocs_os_handle_t os, uint32_t size, uint32_t count)
Allocate an array object.
Definition: ocs_array.c:87
void ocs_array_free(ocs_array_t *array)
Free an array object.
Definition: ocs_array.c:139
uint32_t ocs_array_get_count(ocs_array_t *array)
Return number of elements in an array.
Definition: ocs_array.c:188
uint32_t ocs_varray_get_count(ocs_varray_t *va)
Return entry count for a void pointer array.
Definition: ocs_array.c:408
void ocs_array_set_slablen(uint32_t len)
Set array slab allocation length.
Definition: ocs_array.c:70
void * ocs_varray_iter_next(ocs_varray_t *va)
Return next entry from a void pointer array.
Definition: ocs_array.c:333
void ocs_varray_free(ocs_varray_t *va)
Free a void pointer array.
Definition: ocs_array.c:268
uint32_t size
Definition: ocs_array.c:46
uint32_t entry_count
Definition: ocs_array.c:222
ocs_os_handle_t os
Definition: ocs_array.c:44
int32_t ocs_varray_add(ocs_varray_t *va, void *entry)
Add an entry to a void pointer array.
Definition: ocs_array.c:290
void * ocs_array_get(ocs_array_t *array, uint32_t idx)
Return reference to an element of an array object.
Definition: ocs_array.c:166
ocs_varray_t * ocs_varray_alloc(ocs_os_handle_t os, uint32_t array_count)
Allocate a void pointer array.
Definition: ocs_array.c:238