Do not initialize statics in inline functions (#3111)

* Do not initialize statics in inline functions

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
Anton Kolesnyk 2021-11-17 13:17:41 -08:00 committed by GitHub
parent fe34374b16
commit 5e0f1c9ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 11 deletions

View File

@ -118,15 +118,16 @@ set(
src/io/random_access_file_body_stream.cpp
src/private/environment_log_level_listener.hpp
src/private/package_version.hpp
src/uuid.cpp
src/base64.cpp
src/context.cpp
src/datetime.cpp
src/environment_log_level_listener.cpp
src/etag.cpp
src/exception.cpp
src/logger.cpp
src/operation_status.cpp
src/strings.cpp
src/uuid.cpp
)
add_library(azure-core ${AZURE_CORE_HEADER} ${AZURE_CORE_SOURCE})

View File

@ -183,10 +183,6 @@ public:
* @brief #Azure::Core::ETag representing everything.
* @note The any #Azure::Core::ETag is *, (unquoted). It is NOT the same as "*".
*/
static const ETag& Any()
{
static ETag any = ETag("*");
return any;
}
static const ETag& Any();
};
} // namespace Azure

View File

@ -38,11 +38,7 @@ namespace Azure { namespace Core { namespace IO { namespace _internal {
* @brief Gets a singleton instance of a #Azure::Core::IO::_internal::NullBodyStream.
*
*/
static NullBodyStream* GetNullBodyStream()
{
static NullBodyStream nullBodyStream;
return &nullBodyStream;
}
static NullBodyStream* GetNullBodyStream();
};
}}}} // namespace Azure::Core::IO::_internal

View File

@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "azure/core/etag.hpp"
using Azure::ETag;
const ETag& ETag::Any()
{
static ETag any = ETag("*");
return any;
}

View File

@ -19,6 +19,7 @@
#endif
#include "azure/core/context.hpp"
#include "azure/core/internal/io/null_body_stream.hpp"
#include "azure/core/io/body_stream.hpp"
#include <algorithm>
@ -218,3 +219,11 @@ size_t ProgressBodyStream::OnRead(
}
int64_t ProgressBodyStream::Length() const { return m_bodyStream->Length(); }
using Azure::Core::IO::_internal::NullBodyStream;
NullBodyStream* NullBodyStream::GetNullBodyStream()
{
static NullBodyStream nullBodyStream;
return &nullBodyStream;
}