diff options
author | Adam Langley <agl@google.com> | 2015-05-11 17:20:37 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2015-05-12 23:06:14 +0000 |
commit | e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5 (patch) | |
tree | 6e43e34595ecf887c26c32b86d8ab097fe8cac64 /src/crypto/stack | |
parent | b3106a0cc1493bbe0505c0ec0ce3da4ca90a29ae (diff) | |
download | external_boringssl-e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5.zip external_boringssl-e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5.tar.gz external_boringssl-e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5.tar.bz2 |
external/boringssl: bump revision.
This change bumps the BoringSSL revision to the current tip-of-tree.
Change-Id: I91d5bf467e16e8d86cb19a4de873985f524e5faa
Diffstat (limited to 'src/crypto/stack')
-rw-r--r-- | src/crypto/stack/make_macros.sh | 3 | ||||
-rw-r--r-- | src/crypto/stack/stack.c | 38 |
2 files changed, 34 insertions, 7 deletions
diff --git a/src/crypto/stack/make_macros.sh b/src/crypto/stack/make_macros.sh index f72aa33..4837e44 100644 --- a/src/crypto/stack/make_macros.sh +++ b/src/crypto/stack/make_macros.sh @@ -86,6 +86,9 @@ output_stack () { #define sk_${type}_set_cmp_func(sk, comp)\\ ((int (*) (const ${type} **a, const ${type} **b)) sk_set_cmp_func(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(stack_cmp_func, int (*) (const ${type} **a, const ${type} **b), comp))) +#define sk_${type}_deep_copy(sk, copy_func, free_func)\\ +((STACK_OF(${type})*) sk_deep_copy(CHECKED_CAST(const _STACK*, const STACK_OF(${type})*, sk), CHECKED_CAST(void* (*) (void*), ${ptrtype} (*) (${ptrtype}), copy_func), CHECKED_CAST(void (*) (void*), void (*) (${ptrtype}), free_func))) + EOF } diff --git a/src/crypto/stack/stack.c b/src/crypto/stack/stack.c index 0b336ba..c584515 100644 --- a/src/crypto/stack/stack.c +++ b/src/crypto/stack/stack.c @@ -86,9 +86,7 @@ _STACK *sk_new(stack_cmp_func comp) { return ret; err: - if (ret) { - OPENSSL_free(ret); - } + OPENSSL_free(ret); return NULL; } @@ -232,7 +230,7 @@ int sk_find(_STACK *sk, size_t *out_index, void *p) { int (*comp_func)(const void *,const void *); if (sk == NULL) { - return -1; + return 0; } if (sk->comp == NULL) { @@ -324,9 +322,7 @@ _STACK *sk_dup(const _STACK *sk) { return ret; err: - if (ret) { - sk_free(ret); - } + sk_free(ret); return NULL; } @@ -360,3 +356,31 @@ stack_cmp_func sk_set_cmp_func(_STACK *sk, stack_cmp_func comp) { return old; } + +_STACK *sk_deep_copy(const _STACK *sk, void *(*copy_func)(void *), + void (*free_func)(void *)) { + _STACK *ret = sk_dup(sk); + if (ret == NULL) { + return NULL; + } + + size_t i; + for (i = 0; i < ret->num; i++) { + if (ret->data[i] == NULL) { + continue; + } + ret->data[i] = copy_func(ret->data[i]); + if (ret->data[i] == NULL) { + size_t j; + for (j = 0; j < i; j++) { + if (ret->data[j] != NULL) { + free_func(ret->data[j]); + } + } + sk_free(ret); + return NULL; + } + } + + return ret; +} |