Martin Prikryl c1b9277a66 OpenSSL 3.5.4 пре 3 недеља
..
aes c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
aria 513d92a184 OpenSSL 3.2.0 пре 2 година
asn1 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
async c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
bf 513d92a184 OpenSSL 3.2.0 пре 2 година
bio c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
bn c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
buffer 513d92a184 OpenSSL 3.2.0 пре 2 година
camellia c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cast 513d92a184 OpenSSL 3.2.0 пре 2 година
chacha c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cmac c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cmp c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cms c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
comp 513d92a184 OpenSSL 3.2.0 пре 2 година
conf c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
crmf c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ct 513d92a184 OpenSSL 3.2.0 пре 2 година
des c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
dh c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
dsa c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
dso a322da3810 OpenSSL 3.3.3 пре 9 месеци
ec c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
encode_decode c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
engine c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
err c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ess 1254066655 OpenSSL 3.2.2 пре 1 година
evp c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ffc c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
hashtable c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
hmac c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
hpke c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
http c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
idea c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
kdf 3c34a35624 OpenSSL 3.1.0 пре 2 година
lhash c4c4ebb56d OpenSSL 3.3.1 пре 1 година
md2 3c34a35624 OpenSSL 3.1.0 пре 2 година
md4 3c34a35624 OpenSSL 3.1.0 пре 2 година
md5 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
mdc2 3c34a35624 OpenSSL 3.1.0 пре 2 година
ml_dsa c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ml_kem c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
modes c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
objects c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ocsp c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
pem c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
perlasm c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
pkcs12 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
pkcs7 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
poly1305 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
property c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
rand c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
rc2 513d92a184 OpenSSL 3.2.0 пре 2 година
rc4 513d92a184 OpenSSL 3.2.0 пре 2 година
rc5 513d92a184 OpenSSL 3.2.0 пре 2 година
ripemd 3c34a35624 OpenSSL 3.1.0 пре 2 година
rsa c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
seed 3c34a35624 OpenSSL 3.1.0 пре 2 година
sha c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
siphash 3c34a35624 OpenSSL 3.1.0 пре 2 година
slh_dsa c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
sm2 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
sm3 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
sm4 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
srp c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
stack c4c4ebb56d OpenSSL 3.3.1 пре 1 година
store c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
thread a322da3810 OpenSSL 3.3.3 пре 9 месеци
ts c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
txt_db 513d92a184 OpenSSL 3.2.0 пре 2 година
ui 80313efea9 OpenSSL 3.3.4 пре 5 месеци
whrlpool c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
x509 c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
LPdir_nyi.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
LPdir_unix.c 57fc33d686 OpenSSL 3.1.2 пре 2 година
LPdir_vms.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
LPdir_win.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
LPdir_win32.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
LPdir_wince.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
README-sparse_array.md 3c34a35624 OpenSSL 3.1.0 пре 2 година
alphacpuid.pl 3c34a35624 OpenSSL 3.1.0 пре 2 година
arm64cpuid.pl 3c34a35624 OpenSSL 3.1.0 пре 2 година
arm_arch.h c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
armcap.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
armv4cpuid.pl a322da3810 OpenSSL 3.3.3 пре 9 месеци
asn1_dsa.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
bsearch.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
build.info c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
c64xpluscpuid.pl 3c34a35624 OpenSSL 3.1.0 пре 2 година
comp_methods.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
context.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
core_algorithm.c 513d92a184 OpenSSL 3.2.0 пре 2 година
core_fetch.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
core_namemap.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cpt_err.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cpuid.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
cryptlib.c 513d92a184 OpenSSL 3.2.0 пре 2 година
ctype.c 513d92a184 OpenSSL 3.2.0 пре 2 година
cversion.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
defaults.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
der_writer.c 513d92a184 OpenSSL 3.2.0 пре 2 година
deterministic_nonce.c 1254066655 OpenSSL 3.2.2 пре 1 година
dllmain.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
ebcdic.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
ex_data.c 513d92a184 OpenSSL 3.2.0 пре 2 година
getenv.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
ia64cpuid.S 3c34a35624 OpenSSL 3.1.0 пре 2 година
indicator_core.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
info.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
init.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
initthread.c a322da3810 OpenSSL 3.3.3 пре 9 месеци
loongarch64cpuid.pl 80313efea9 OpenSSL 3.3.4 пре 5 месеци
loongarch_arch.h d8f092ac60 OpenSSL 3.1.3 пре 2 година
loongarchcap.c 57fc33d686 OpenSSL 3.1.2 пре 2 година
mem.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
mem_clr.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
mem_sec.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
mips_arch.h 3c34a35624 OpenSSL 3.1.0 пре 2 година
o_dir.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
o_fopen.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
o_init.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
o_str.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
o_time.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
packet.c 513d92a184 OpenSSL 3.2.0 пре 2 година
param_build.c c4c4ebb56d OpenSSL 3.3.1 пре 1 година
param_build_set.c c4c4ebb56d OpenSSL 3.3.1 пре 1 година
params.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
params_dup.c 80313efea9 OpenSSL 3.3.4 пре 5 месеци
params_from_text.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
params_idx.c.in 513d92a184 OpenSSL 3.2.0 пре 2 година
pariscid.pl 3c34a35624 OpenSSL 3.1.0 пре 2 година
passphrase.c 513d92a184 OpenSSL 3.2.0 пре 2 година
ppccap.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ppccpuid.pl 3c34a35624 OpenSSL 3.1.0 пре 2 година
provider.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
provider_child.c 513d92a184 OpenSSL 3.2.0 пре 2 година
provider_conf.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
provider_core.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
provider_local.h 3c34a35624 OpenSSL 3.1.0 пре 2 година
provider_predefined.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
punycode.c 513d92a184 OpenSSL 3.2.0 пре 2 година
quic_vlint.c 513d92a184 OpenSSL 3.2.0 пре 2 година
rcu_internal.h c4c4ebb56d OpenSSL 3.3.1 пре 1 година
riscv32cpuid.pl 6ec29a5a18 OpenSSL 3.3.5 пре 2 месеци
riscv64cpuid.pl 6ec29a5a18 OpenSSL 3.3.5 пре 2 месеци
riscvcap.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
s390x_arch.h c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
s390xcap.c a322da3810 OpenSSL 3.3.3 пре 9 месеци
s390xcpuid.pl c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
self_test_core.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
sleep.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
sparccpuid.S 3c34a35624 OpenSSL 3.1.0 пре 2 година
sparcv9cap.c 3c34a35624 OpenSSL 3.1.0 пре 2 година
sparse_array.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
ssl_err.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
sslerr.h c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
threads_lib.c 513d92a184 OpenSSL 3.2.0 пре 2 година
threads_none.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
threads_pthread.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
threads_win.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
time.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
trace.c c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
uid.c 513d92a184 OpenSSL 3.2.0 пре 2 година
vms_rms.h 3c34a35624 OpenSSL 3.1.0 пре 2 година
x86_64cpuid.pl c1b9277a66 OpenSSL 3.5.4 пре 2 недеља
x86cpuid.pl c1b9277a66 OpenSSL 3.5.4 пре 2 недеља

README-sparse_array.md

Sparse Arrays

The sparse_array.c file contains an implementation of a sparse array that attempts to be both space and time efficient.

The sparse array is represented using a tree structure. Each node in the tree contains a block of pointers to either the user supplied leaf values or to another node.

There are a number of parameters used to define the block size:

OPENSSL_SA_BLOCK_BITS   Specifies the number of bits covered by each block
SA_BLOCK_MAX            Specifies the number of pointers in each block
SA_BLOCK_MASK           Specifies a bit mask to perform modulo block size
SA_BLOCK_MAX_LEVELS     Indicates the maximum possible height of the tree

These constants are inter-related:

SA_BLOCK_MAX        = 2 ^ OPENSSL_SA_BLOCK_BITS
SA_BLOCK_MASK       = SA_BLOCK_MAX - 1
SA_BLOCK_MAX_LEVELS = number of bits in size_t divided by
                      OPENSSL_SA_BLOCK_BITS rounded up to the next multiple
                      of OPENSSL_SA_BLOCK_BITS

OPENSSL_SA_BLOCK_BITS can be defined at compile time and this overrides the built in setting.

As a space and performance optimisation, the height of the tree is usually less than the maximum possible height. Only sufficient height is allocated to accommodate the largest index added to the data structure.

The largest index used to add a value to the array determines the tree height:

    +----------------------+---------------------+
    | Largest Added Index  |   Height of Tree    |
    +----------------------+---------------------+
    | SA_BLOCK_MAX     - 1 |          1          |
    | SA_BLOCK_MAX ^ 2 - 1 |          2          |
    | SA_BLOCK_MAX ^ 3 - 1 |          3          |
    | ...                  |          ...        |
    | size_t max           | SA_BLOCK_MAX_LEVELS |
    +----------------------+---------------------+

The tree height is dynamically increased as needed based on additions.

An empty tree is represented by a NULL root pointer. Inserting a value at index 0 results in the allocation of a top level node full of null pointers except for the single pointer to the user's data (N = SA_BLOCK_MAX for brevity):

    +----+
    |Root|
    |Node|
    +-+--+
      |
      |
      |
      v
    +-+-+---+---+---+---+
    | 0 | 1 | 2 |...|N-1|
    |   |nil|nil|...|nil|
    +-+-+---+---+---+---+
      |
      |
      |
      v
    +-+--+
    |User|
    |Data|
    +----+
Index 0

Inserting at element 2N+1 creates a new root node and pushes down the old root node. It then creates a second second level node to hold the pointer to the user's new data:

    +----+
    |Root|
    |Node|
    +-+--+
      |
      |
      |
      v
    +-+-+---+---+---+---+
    | 0 | 1 | 2 |...|N-1|
    |   |nil|   |...|nil|
    +-+-+---+-+-+---+---+
      |       |
      |       +------------------+
      |                          |
      v                          v
    +-+-+---+---+---+---+      +-+-+---+---+---+---+
    | 0 | 1 | 2 |...|N-1|      | 0 | 1 | 2 |...|N-1|
    |nil|   |nil|...|nil|      |nil|   |nil|...|nil|
    +-+-+---+---+---+---+      +---+-+-+---+---+---+
      |                              |
      |                              |
      |                              |
      v                              v
    +-+--+                         +-+--+
    |User|                         |User|
    |Data|                         |Data|
    +----+                         +----+
Index 0                       Index 2N+1

The nodes themselves are allocated in a sparse manner. Only nodes which exist along a path from the root of the tree to an added leaf will be allocated. The complexity is hidden and nodes are allocated on an as needed basis. Because the data is expected to be sparse this doesn't result in a large waste of space.

Values can be removed from the sparse array by setting their index position to NULL. The data structure does not attempt to reclaim nodes or reduce the height of the tree on removal. For example, now setting index 0 to NULL would result in:

    +----+
    |Root|
    |Node|
    +-+--+
      |
      |
      |
      v
    +-+-+---+---+---+---+
    | 0 | 1 | 2 |...|N-1|
    |   |nil|   |...|nil|
    +-+-+---+-+-+---+---+
      |       |
      |       +------------------+
      |                          |
      v                          v
    +-+-+---+---+---+---+      +-+-+---+---+---+---+
    | 0 | 1 | 2 |...|N-1|      | 0 | 1 | 2 |...|N-1|
    |nil|nil|nil|...|nil|      |nil|   |nil|...|nil|
    +---+---+---+---+---+      +---+-+-+---+---+---+
                                     |
                                     |
                                     |
                                     v
                                   +-+--+
                                   |User|
                                   |Data|
                                   +----+
                              Index 2N+1

Accesses to elements in the sparse array take O(log n) time where n is the largest element. The base of the logarithm is SA_BLOCK_MAX, so for moderately small indices (e.g. NIDs), single level (constant time) access is achievable. Space usage is O(minimum(m, n log(n)) where m is the number of elements in the array.

Note: sparse arrays only include pointers to types. Thus, SPARSE_ARRAY_OF(char) can be used to store a string.