summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPaul Yang <yang.yang@baishancloud.com>2017-10-20 01:42:39 +0800
committerPauli <paul.dale@oracle.com>2017-10-26 09:35:36 +1000
commit3ceab379fbaaf11b2adee0fb2a93c517272ee6c3 (patch)
treea1c7b3f6fedd09b9afca618c8cecaf941e062096 /include
parent82d89ef72515ad3d78c0160641faf30b8b024dda (diff)
Add sk_TYPE_new_reserve() function
This is a combination of sk_new and sk_reserve, to make it more convenient to allocate a new stack with reserved memory and comaprison function (if any). Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4559)
Diffstat (limited to 'include')
-rw-r--r--include/openssl/safestack.h4
-rw-r--r--include/openssl/stack.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/include/openssl/safestack.h b/include/openssl/safestack.h
index 4241c4ff3b..7438b19360 100644
--- a/include/openssl/safestack.h
+++ b/include/openssl/safestack.h
@@ -40,6 +40,10 @@ extern "C" {
{ \
return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \
} \
+ static ossl_inline STACK_OF(t1) *sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \
+ { \
+ return (STACK_OF(t1) *)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); \
+ } \
static ossl_inline int sk_##t1##_reserve(STACK_OF(t1) *sk, int n) \
{ \
return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \
diff --git a/include/openssl/stack.h b/include/openssl/stack.h
index aee763c196..cfc075057a 100644
--- a/include/openssl/stack.h
+++ b/include/openssl/stack.h
@@ -27,6 +27,7 @@ void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data);
OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp);
OPENSSL_STACK *OPENSSL_sk_new_null(void);
+OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n);
int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n);
void OPENSSL_sk_free(OPENSSL_STACK *);
void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *));