BSL v0.0.0
AMMOS Bundle Protocol Security Library (BSL)
|
Implementation of the data containers for handling variable-sized buffers and ownership. More...
Go to the source code of this file.
Functions | |
static void | bsl_data_int_reset (BSL_Data_t *data) |
static void | bsl_data_int_free (BSL_Data_t *data) |
int | BSL_Data_Init (BSL_Data_t *data) |
Initialize an empty data struct. | |
int | BSL_Data_InitBuffer (BSL_Data_t *data, size_t bytelen) |
Initialize with an owned buffer of size bytelen. | |
int | BSL_Data_InitView (BSL_Data_t *data, size_t len, const BSL_DataPtr_t src) |
Initialize a data struct as an overlay on optional external data. | |
void | BSL_Data_InitMove (BSL_Data_t *data, BSL_Data_t *src) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
int | BSL_Data_Deinit (BSL_Data_t *data) |
De-initialize a data struct, freeing if necessary. | |
int | BSL_Data_CopyFrom (BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src) |
Set an initialized data struct to a given size. | |
int | BSL_Data_Resize (BSL_Data_t *data, size_t len) |
Resize the data, copying if necessary. | |
int | BSL_Data_AppendFrom (BSL_Data_t *data, size_t len, BSL_DataConstPtr_t src) |
Append an initialized data struct with a given size. | |
Implementation of the data containers for handling variable-sized buffers and ownership.
Definition in file UtilDefs_Data.c.
int BSL_Data_AppendFrom | ( | BSL_Data_t * | data, |
size_t | len, | ||
BSL_DataConstPtr_t | src | ||
) |
Append an initialized data struct with a given size.
[in,out] | data | The data to copy into, which must not be NULL. |
len | The total length to allocate, which may be non-zero. | |
src | An optional source buffer to copy from, from which len bytes will be copied. |
Definition at line 164 of file UtilDefs_Data.c.
References BSL_Data_Resize(), BSL_LOG_ERR, BSL_SUCCESS, BSL_Data_s::len, and BSL_Data_s::ptr.
int BSL_Data_CopyFrom | ( | BSL_Data_t * | data, |
size_t | len, | ||
BSL_DataConstPtr_t | src | ||
) |
Set an initialized data struct to a given size.
[in,out] | data | The data to copy into, which must not be NULL. |
len | The total length to allocate, which may be non-zero. | |
src | An optional source buffer to copy from, from which len bytes will be copied. |
Definition at line 100 of file UtilDefs_Data.c.
References BSL_Data_Resize(), BSL_LOG_ERR, BSL_SUCCESS, BSL_Data_s::owned, and BSL_Data_s::ptr.
Referenced by BSL_Crypto_AddRegistryKey(), and bsl_mock_decode_eid().
int BSL_Data_Deinit | ( | BSL_Data_t * | data | ) |
De-initialize a data struct, freeing if necessary.
[in,out] | data | The data to de-initialize, which must not be NULL. |
Definition at line 92 of file UtilDefs_Data.c.
References BSL_SUCCESS.
Referenced by bsl_mock_eid_deinit(), and BSL_SecOutcome_Deinit().
int BSL_Data_Init | ( | BSL_Data_t * | data | ) |
Initialize an empty data struct.
[in,out] | data | The data to initialize, which must not be NULL. |
Definition at line 50 of file UtilDefs_Data.c.
References BSL_SUCCESS.
Referenced by BSL_Crypto_AddRegistryKey(), and bsl_mock_decode_eid().
int BSL_Data_InitBuffer | ( | BSL_Data_t * | data, |
size_t | bytelen | ||
) |
Initialize with an owned buffer of size bytelen.
[in,out] | data | The data to initialize. |
bytelen | Length of buffer to allocate. |
Definition at line 57 of file UtilDefs_Data.c.
References BSL_SUCCESS, BSL_Data_s::len, BSL_Data_s::owned, and BSL_Data_s::ptr.
Referenced by BSL_SecOutcome_Init().
void BSL_Data_InitMove | ( | BSL_Data_t * | data, |
BSL_Data_t * | src | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 84 of file UtilDefs_Data.c.
int BSL_Data_InitView | ( | BSL_Data_t * | data, |
size_t | len, | ||
BSL_DataPtr_t | src | ||
) |
Initialize a data struct as an overlay on optional external data.
[in,out] | data | The data to initialize, which must not be NULL. |
len | The total length to allocate, which may be zero. | |
src | An optional source buffer to point to. |
Definition at line 72 of file UtilDefs_Data.c.
References BSL_SUCCESS, BSL_Data_s::len, BSL_Data_s::owned, and BSL_Data_s::ptr.
Referenced by BSL_API_QuerySecurity(), and BSL_SecParam_GetAsBytestr().
|
static |
Definition at line 40 of file UtilDefs_Data.c.
|
static |
Definition at line 30 of file UtilDefs_Data.c.
int BSL_Data_Resize | ( | BSL_Data_t * | data, |
size_t | len | ||
) |
Resize the data, copying if necessary.
[in,out] | data | The data to resize, which must not be NULL. |
len | The new total size. |
Definition at line 131 of file UtilDefs_Data.c.
References BSL_ERR_INSUFFICIENT_SPACE, BSL_LOG_ERR, BSL_SUCCESS, BSL_Data_s::len, BSL_Data_s::owned, BSL_Data_s::ptr, and UNLIKELY.
Referenced by BSL_Data_AppendFrom(), and BSL_Data_CopyFrom().