69 return ocs_malloc(os,
sizeof(
void*) * rowcount, OCS_M_ZERO | OCS_M_NOWAIT);
87 spv_del_row(
void **row, uint32_t rowcount)
89 ocs_free(row,
sizeof(
void*) * rowcount);
107 spv_get_max_idx(sparse_vector_t spv)
128 _spv_del(ocs_os_handle_t os,
void **a, uint32_t n, uint32_t depth)
134 for (i = 0; i < n; i ++) {
157 ocs_free(spv->os, spv,
sizeof(*spv));
178 spv = ocs_malloc(os,
sizeof(*spv), OCS_M_ZERO | OCS_M_NOWAIT);
185 for (i = 0; i <
SPV_DIM; i ++) {
208 *
spv_new_cell(sparse_vector_t sv, uint32_t idx, uint8_t alloc_new_rows)
210 uint32_t a = (idx >> 16) & 0xff;
211 uint32_t b = (idx >> 8) & 0xff;
212 uint32_t c = (idx >> 0) & 0xff;
215 if (idx >= sv->max_idx) {
219 if (sv->array == NULL) {
221 if (sv->array == NULL) {
258 spv_set(sparse_vector_t sv, uint32_t idx,
void *value)
static void _spv_del(ocs_os_handle_t os, void **a, uint32_t n, uint32_t depth)
Delete row recursively.
static void ** spv_new_row(ocs_os_handle_t os, uint32_t rowcount)
Allocate a new sparse vector row.
void * spv_get(sparse_vector_t sv, uint32_t idx)
Return the sparse vector cell value.
static void * spv_new_cell(sparse_vector_t sv, uint32_t idx, uint8_t alloc_new_rows)
Return the address of a cell.
sparse_vector_t spv_new(ocs_os_handle_t os)
Instantiate a new sparse vector object.
void spv_del(sparse_vector_t spv)
Delete a sparse vector.
void spv_set(sparse_vector_t sv, uint32_t idx, void *value)
Set the sparse vector cell value.