Vector 0.0.2
Loading...
Searching...
No Matches
Lifetime

Constructors/Destructors. More...

Collaboration diagram for Lifetime:

Macros

#define alloc_opts(...)   (alloc_opts_t){__VA_ARGS__}
 Use this macro to define allocator opts in vector_opts_t.
 
#define vector_create(...)
 Vector constructor.
 

Functions

vector_tvector_create_ (const vector_opts_t *const opts)
 Vector contructor.
 
void vector_destroy (vector_t *const vector)
 Deallocates vector.
 
vector_tvector_clone (const vector_t *const vector)
 Duplicates a vector.
 
vector_status_t vector_resize (vector_t **const vector, const size_t capacity, const vector_status_t error)
 Performs allocation resize.
 

Detailed Description

Constructors/Destructors.

Macro Definition Documentation

◆ alloc_opts

#define alloc_opts ( ...)    (alloc_opts_t){__VA_ARGS__}

Use this macro to define allocator opts in vector_opts_t.

Examples
aligned_alloc.c.

Definition at line 153 of file vector.h.

◆ vector_create

#define vector_create ( ...)
Value:
__VA_ARGS__ \
}\
)\
vector_t * vector_create_(const vector_opts_t *const opts)
Vector contructor.
Definition vector.c:82
Vector options.
Definition vector.h:52
#define VECTOR_DEFAULT_ARGS
Definition vector.h:78

Vector constructor.

Preferable way to invoke vector constructor. Provides default values.

Warning
element_size is mandatory!
See also
vector_create_
Examples
aligned_alloc.c, create.c, and polymorph.c.

Definition at line 162 of file vector.h.

Function Documentation

◆ vector_create_()

vector_t * vector_create_ ( const vector_opts_t *const opts)

Vector contructor.

Vector constructor function that initializes vector with properties packed in opts struct. Space for initial_cap elements will be reserved. In case of allocation fail null pointer will be returned via vector argument.

Parameters
[in]optsOptions according to which vector will be created.
Returns
Fresh new instance of the vector or NULL if allocation failed.

Definition at line 82 of file vector.c.

Here is the call graph for this function:

◆ vector_destroy()

void vector_destroy ( vector_t *const vector)

Deallocates vector.

A pointer will be invalidated after the call.

Parameters
[in]vectorVector pointer that will be deallocated.

Definition at line 112 of file vector.c.

Here is the call graph for this function:

◆ vector_clone()

vector_t * vector_clone ( const vector_t *const vector)

Duplicates a vector.

Makes an exact copy of the whole vector. (Allocation may fail).

Parameters
[in]vectorVector prototype to be copied.
Returns
Copy of the vector on success, NULL pointer otherwise.

Definition at line 119 of file vector.c.

Here is the call graph for this function:

◆ vector_resize()

vector_status_t vector_resize ( vector_t **const vector,
const size_t capacity,
const vector_status_t error )

Performs allocation resize.

Resizes vector to a desired capacity, wiping out elements beyond new capacity bounds. Takes third parameter which denotes error type that will be returned if resize fails.

Parameters
[in]vectorReference to vectors pointer.
[in]capacityDesired vectors capacity.
[in]errorExtension feature, error status code that will be returned upon allocation failure.
Returns
Operation status.

Definition at line 141 of file vector.c.

Here is the call graph for this function: