Debian Codegraph @

intl/components/src/ICU4XGeckoDataProvider.cpp

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #include "ICU4XGeckoDataProvider.h"
6
7 #include "ICU4XDataProvider.h"
8 #include "mozilla/Assertions.h"
9
10 #include <mutex>
11
12 namespace mozilla::intl {
13
14 static capi::ICU4XDataProvider* sICU4XDataProvider = nullptr;
15
16 capi::ICU4XDataProvider* GetDataProvider() {
17 static std::once_flag sOnce;
18
19 std::call_once(sOnce, []() {
20 sICU4XDataProvider = capi::ICU4XDataProvider_create_compiled();
21 });
22
23 return sICU4XDataProvider;
24 }
25
26 void CleanupDataProvider() {
27 if (!sICU4XDataProvider) {
28 return;
29 }
30
31 capi::ICU4XDataProvider_destroy(sICU4XDataProvider);
32 sICU4XDataProvider = nullptr;
33 }
34
35 } // namespace mozilla::intl