store_init.c 815 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <openssl/err.h>
  10. #include "crypto/store.h"
  11. #include "store_local.h"
  12. static CRYPTO_ONCE store_init = CRYPTO_ONCE_STATIC_INIT;
  13. DEFINE_RUN_ONCE_STATIC(do_store_init)
  14. {
  15. return OPENSSL_init_crypto(0, NULL);
  16. }
  17. int ossl_store_init_once(void)
  18. {
  19. if (!RUN_ONCE(&store_init, do_store_init)) {
  20. ERR_raise(ERR_LIB_OSSL_STORE, ERR_R_MALLOC_FAILURE);
  21. return 0;
  22. }
  23. return 1;
  24. }
  25. void ossl_store_cleanup_int(void)
  26. {
  27. ossl_store_destroy_loaders_int();
  28. }