Emulex Logo
OneCoreā„¢ Storage SDK Release 11.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ocs_array.c File Reference
#include "ocs.h"
#include "ocs_array.h"

Go to the source code of this file.

Data Structures

struct  ocs_array_t
 
struct  ocs_varray_t
 Void pointer array structure. More...
 

Macros

#define DEFAULT_SLAB_LEN   (16*1024)
 

Functions

void ocs_array_set_slablen (uint32_t len)
 Set array slab allocation length. More...
 
ocs_array_t * ocs_array_alloc (ocs_os_handle_t os, uint32_t size, uint32_t count)
 Allocate an array object. More...
 
void ocs_array_free (ocs_array_t *array)
 Free an array object. More...
 
void * ocs_array_get (ocs_array_t *array, uint32_t idx)
 Return reference to an element of an array object. More...
 
uint32_t ocs_array_get_count (ocs_array_t *array)
 Return number of elements in an array. More...
 
uint32_t ocs_array_get_size (ocs_array_t *array)
 Return size of array elements in bytes. More...
 
ocs_varray_t * ocs_varray_alloc (ocs_os_handle_t os, uint32_t array_count)
 Allocate a void pointer array. More...
 
void ocs_varray_free (ocs_varray_t *va)
 Free a void pointer array. More...
 
int32_t ocs_varray_add (ocs_varray_t *va, void *entry)
 Add an entry to a void pointer array. More...
 
void ocs_varray_iter_reset (ocs_varray_t *va)
 Reset the void pointer array iterator. More...
 
void * ocs_varray_iter_next (ocs_varray_t *va)
 Return next entry from a void pointer array. More...
 
void * _ocs_varray_iter_next (ocs_varray_t *va)
 Return next entry from a void pointer array. More...
 
void ocs_varray_lock (ocs_varray_t *va)
 Take void pointer array lock. More...
 
void ocs_varray_unlock (ocs_varray_t *va)
 Release void pointer array lock. More...
 
uint32_t ocs_varray_get_count (ocs_varray_t *va)
 Return entry count for a void pointer array. More...
 

Variables

static uint32_t slab_len = DEFAULT_SLAB_LEN
 

Macro Details

#define DEFAULT_SLAB_LEN   (16*1024)

Definition at line 41 of file ocs_array.c.

Function Details

void* _ocs_varray_iter_next ( ocs_varray_t *  va)

Return next entry from a void pointer array.

The next entry in the void pointer array is returned.

Parameters
vaPointer to void point array

Note: doesn't take the void pointer array lock

Returns
returns next void pointer entry

Definition at line 357 of file ocs_array.c.

ocs_array_t* ocs_array_alloc ( ocs_os_handle_t  os,
uint32_t  size,
uint32_t  count 
)

Allocate an array object.

An array object of size and number of elements is allocated

Parameters
osOS handle
sizesize of array elements in bytes
countnumber of elements in array
Returns
pointer to array object or NULL

Definition at line 87 of file ocs_array.c.

void ocs_array_free ( ocs_array_t *  array)

Free an array object.

Frees a prevously allocated array object

Parameters
arraypointer to array object
Returns
none

Definition at line 139 of file ocs_array.c.

void* ocs_array_get ( ocs_array_t *  array,
uint32_t  idx 
)

Return reference to an element of an array object.

Return the address of an array element given an index

Parameters
arraypointer to array object
idxarray element index
Returns
rointer to array element, or NULL if index out of range

Definition at line 166 of file ocs_array.c.

uint32_t ocs_array_get_count ( ocs_array_t *  array)

Return number of elements in an array.

Return the number of elements in an array

Parameters
arraypointer to array object
Returns
returns count of elements in an array

Definition at line 188 of file ocs_array.c.

uint32_t ocs_array_get_size ( ocs_array_t *  array)

Return size of array elements in bytes.

Returns the size in bytes of each array element

Parameters
arraypointer to array object
Returns
size of array element

Definition at line 203 of file ocs_array.c.

void ocs_array_set_slablen ( uint32_t  len)

Set array slab allocation length.

The slab length is the maximum allocation length that the array uses. The default 64k slab length may be overridden using this function.

Parameters
lennew slab length.
Returns
none

Definition at line 70 of file ocs_array.c.

int32_t ocs_varray_add ( ocs_varray_t *  va,
void *  entry 
)

Add an entry to a void pointer array.

An entry is added to the void pointer array

Parameters
vaPointer to void pointer array
entryPointer to entry to add
Returns
returns 0 if entry was added, -1 if there is no more space in the array

Definition at line 290 of file ocs_array.c.

ocs_varray_t* ocs_varray_alloc ( ocs_os_handle_t  os,
uint32_t  array_count 
)

Allocate a void pointer array.

A void pointer array of given length is allocated.

Parameters
osOS handle
array_countArray size
Returns
returns a pointer to the ocs_varray_t object, other NULL on error

Definition at line 238 of file ocs_array.c.

void ocs_varray_free ( ocs_varray_t *  va)

Free a void pointer array.

The void pointer array object is free'd

Parameters
vaPointer to void pointer array
Returns
none

Definition at line 268 of file ocs_array.c.

uint32_t ocs_varray_get_count ( ocs_varray_t *  va)

Return entry count for a void pointer array.

The entry count for a void pointer array is returned

Parameters
vaPointer to void pointer array
Returns
returns entry count

Definition at line 408 of file ocs_array.c.

void* ocs_varray_iter_next ( ocs_varray_t *  va)

Return next entry from a void pointer array.

The next entry in the void pointer array is returned.

Parameters
vaPointer to void point array

Note: takes the void pointer array lock

Returns
returns next void pointer entry

Definition at line 333 of file ocs_array.c.

void ocs_varray_iter_reset ( ocs_varray_t *  va)

Reset the void pointer array iterator.

The next index value of the void pointer array iterator is cleared.

Parameters
vaPointer to void pointer array
Returns
none

Definition at line 314 of file ocs_array.c.

void ocs_varray_lock ( ocs_varray_t *  va)

Take void pointer array lock.

Takes the lock for the given void pointer array

Parameters
vaPointer to void pointer array
Returns
none

Definition at line 378 of file ocs_array.c.

void ocs_varray_unlock ( ocs_varray_t *  va)

Release void pointer array lock.

Releases the lock for the given void pointer array

Parameters
vaPointer to void pointer array
Returns
none

Definition at line 393 of file ocs_array.c.

Variable Details

uint32_t slab_len = DEFAULT_SLAB_LEN
static

Definition at line 57 of file ocs_array.c.