Convert stack.h to use inline functions.
Instead of a script which generates macros, emit static inlines in
individual header (or C files). This solves a few issues with the
original setup:
- The documentation was off. We match the documentation now.
- The stack macros did not check constness; see some of the fixes in
crypto/x509.
- Type errors did not look like usual type errors.
- Any type which participated in STACK_OF had to be made partially
public. This allows stack types to be defined an internal header or
even an individual file.
- One could not pass sk_FOO_free into something which expects a function
pointer.
Thanks to upstream's 411abf2dd37974a5baa54859c1abcd287b3c1181 for the
idea.
Change-Id: Ie5431390ccad761c17596b0e93941b0d7a68f904
Reviewed-on: https://boringssl-review.googlesource.com/16087
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index 914b275..52e5df0 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -111,6 +111,7 @@
int (*i2a)(void);
} /* X509_OBJECTS */;
+DEFINE_STACK_OF(X509_ALGOR)
DECLARE_ASN1_SET_OF(X509_ALGOR)
typedef STACK_OF(X509_ALGOR) X509_ALGORS;
@@ -142,7 +143,7 @@
int size; /* temp variable */
} /* X509_NAME_ENTRY */;
-DECLARE_STACK_OF(X509_NAME_ENTRY)
+DEFINE_STACK_OF(X509_NAME_ENTRY)
DECLARE_ASN1_SET_OF(X509_NAME_ENTRY)
/* we always keep X509_NAMEs in 2 forms. */
@@ -160,7 +161,7 @@
int canon_enclen;
} /* X509_NAME */;
-DECLARE_STACK_OF(X509_NAME)
+DEFINE_STACK_OF(X509_NAME)
#define X509_EX_V_NETSCAPE_HACK 0x8000
#define X509_EX_V_INIT 0x0001
@@ -173,7 +174,7 @@
typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS;
-DECLARE_STACK_OF(X509_EXTENSION)
+DEFINE_STACK_OF(X509_EXTENSION)
DECLARE_ASN1_SET_OF(X509_EXTENSION)
/* a sequence of these are used */
@@ -188,7 +189,7 @@
} value;
} /* X509_ATTRIBUTE */;
-DECLARE_STACK_OF(X509_ATTRIBUTE)
+DEFINE_STACK_OF(X509_ATTRIBUTE)
DECLARE_ASN1_SET_OF(X509_ATTRIBUTE)
@@ -240,6 +241,9 @@
STACK_OF(X509_ALGOR) *other; /* other unspecified info */
} /* X509_CERT_AUX */;
+DECLARE_STACK_OF(DIST_POINT)
+DECLARE_STACK_OF(GENERAL_NAME)
+
struct x509_st
{
X509_CINF *cert_info;
@@ -267,7 +271,7 @@
CRYPTO_MUTEX lock;
} /* X509 */;
-DECLARE_STACK_OF(X509)
+DEFINE_STACK_OF(X509)
DECLARE_ASN1_SET_OF(X509)
/* This is used for a table of trust checking functions */
@@ -281,7 +285,7 @@
void *arg2;
} /* X509_TRUST */;
-DECLARE_STACK_OF(X509_TRUST)
+DEFINE_STACK_OF(X509_TRUST)
struct x509_cert_pair_st {
X509 *forward;
@@ -403,7 +407,7 @@
int sequence; /* load sequence */
};
-DECLARE_STACK_OF(X509_REVOKED)
+DEFINE_STACK_OF(X509_REVOKED)
DECLARE_ASN1_SET_OF(X509_REVOKED)
struct X509_crl_info_st
@@ -418,6 +422,8 @@
ASN1_ENCODING enc;
} /* X509_CRL_INFO */;
+DECLARE_STACK_OF(GENERAL_NAMES)
+
struct X509_crl_st
{
/* actual signature */
@@ -441,7 +447,7 @@
void *meth_data;
} /* X509_CRL */;
-DECLARE_STACK_OF(X509_CRL)
+DEFINE_STACK_OF(X509_CRL)
DECLARE_ASN1_SET_OF(X509_CRL)
struct private_key_st
@@ -476,7 +482,7 @@
} /* X509_INFO */;
-DECLARE_STACK_OF(X509_INFO)
+DEFINE_STACK_OF(X509_INFO)
#endif
/* The next 2 structures and their 8 routines were sent to me by