summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tobias.markmann@isode.com>2019-10-18 06:19:53 (GMT)
committerTobias Markmann <tobias.markmann@isode.com>2019-10-18 06:19:53 (GMT)
commit7de9a3489c3e2ddc4c0ab78f43649c5d6be20aca (patch)
treee0cfb4493ae07c3aa2270d3b94a1eb66ff4956dc /Swiften/IDN
parent2239cdae45b39e675877ae32c86c47bcadce3090 (diff)
downloadswift-7de9a3489c3e2ddc4c0ab78f43649c5d6be20aca.zip
swift-7de9a3489c3e2ddc4c0ab78f43649c5d6be20aca.tar.bz2
Return unique_ptr in PlatformIDNConverter::create()
There are cases where users of this method forget to free the pointer. This is now avoided by returning a unique_ptr. Test-Information: All existing unit and integration tests, i.e. `./scons test=all` pass. Change-Id: I10a88c3361823074d81db7af8cec1bd70c409995
Diffstat (limited to 'Swiften/IDN')
-rw-r--r--Swiften/IDN/PlatformIDNConverter.cpp10
-rw-r--r--Swiften/IDN/PlatformIDNConverter.h6
2 files changed, 9 insertions, 7 deletions
diff --git a/Swiften/IDN/PlatformIDNConverter.cpp b/Swiften/IDN/PlatformIDNConverter.cpp
index c6104fb..3564bb9 100644
--- a/Swiften/IDN/PlatformIDNConverter.cpp
+++ b/Swiften/IDN/PlatformIDNConverter.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2018 Isode Limited.
+ * Copyright (c) 2012-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -13,16 +13,16 @@
namespace Swift {
-IDNConverter* PlatformIDNConverter::create() {
+std::unique_ptr<IDNConverter> PlatformIDNConverter::create() {
#if defined(HAVE_LIBIDN)
- return new LibIDNConverter();
+ return std::make_unique<LibIDNConverter>();
#elif defined(HAVE_ICU)
- return new ICUConverter();
+ return std::make_unique<ICUConverter>();
#else
#if defined(NEED_IDN)
#error "No IDN implementation"
#else
- return nullptr;
+ return {};
#endif
#endif
}
diff --git a/Swiften/IDN/PlatformIDNConverter.h b/Swiften/IDN/PlatformIDNConverter.h
index 704f7a7..3b9a275 100644
--- a/Swiften/IDN/PlatformIDNConverter.h
+++ b/Swiften/IDN/PlatformIDNConverter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012 Isode Limited.
+ * Copyright (c) 2012-2019 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,10 +8,12 @@
#include <Swiften/Base/API.h>
+#include <memory>
+
namespace Swift {
class IDNConverter;
namespace PlatformIDNConverter {
- SWIFTEN_API IDNConverter* create();
+ SWIFTEN_API std::unique_ptr<IDNConverter> create();
}
}