Precompute sorted array for error strings.
Previously, error strings were kept in arrays for each subdirectory and
err.c would iterate over them all and insert them at init time to a hash
table.
This means that, even if you have a shared library and lots of processes
using that, each process has ~30KB of private memory from building that
hash table.
This this change, all the error strings are built into a sorted list and
are thus static data. This means that processes can share the error
information and it actually saves binary space because of all the
pointer overhead in the old scheme. Also it saves the time taken
building the hash table at startup.
This removes support for externally-supplied error string data.
Change-Id: Ifca04f335c673a048e1a3e76ff2b69c7264635be
diff --git a/include/openssl/err.h b/include/openssl/err.h
index c749659..4e318dd 100644
--- a/include/openssl/err.h
+++ b/include/openssl/err.h
@@ -142,10 +142,7 @@
/* Startup and shutdown. */
-/* ERR_load_crypto_strings initialises the error string hash with builtin
- * values. If this is not called then the string forms of errors produced by
- * the functions below will contain numeric identifiers rather than
- * human-readable strings. */
+/* ERR_load_crypto_strings does nothing. */
OPENSSL_EXPORT void ERR_load_crypto_strings(void);
/* ERR_free_strings frees any memory retained by the error system, expect for
@@ -474,24 +471,10 @@
#define ERR_GET_FUNC(packed_error) ((int)(((packed_error) >> 12) & 0xfff))
#define ERR_GET_REASON(packed_error) ((int)((packed_error) & 0xfff))
-/* ERR_STRING_DATA is the type of an lhash node that contains a mapping from a
- * library, function or reason code to a string representation of it. */
-typedef struct err_string_data_st {
- uint32_t error;
- const char *string;
-} ERR_STRING_DATA;
-
-/* ERR_load_strings loads an array of ERR_STRING_DATA into the hash table. The
- * array must be terminated by an entry with a NULL string. */
-OPENSSL_EXPORT void ERR_load_strings(const ERR_STRING_DATA *str);
-
/* ERR_FNS_st is a structure of function pointers that contains the actual
* implementation of the error queue handling functions. */
struct ERR_FNS_st {
void (*shutdown)(void (*err_state_free_cb)(ERR_STATE*));
- ERR_STRING_DATA *(*get_item)(uint32_t packed_error);
- ERR_STRING_DATA *(*set_item)(const ERR_STRING_DATA *);
- ERR_STRING_DATA *(*del_item)(uint32_t packed_error);
/* get_state returns the ERR_STATE for the current thread. This function
* never returns NULL. */