summaryrefslogtreecommitdiff
path: root/src/DownloadContext.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-26 23:56:43 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-26 23:56:43 +0900
commitda7400ef5c62ee144fc14ba7ca4745349f0b0c72 (patch)
treeb0d023eecfcfcca2a88eb3466baf878bdff9f4c1 /src/DownloadContext.cc
parent47402c5f29cb806f73aae2ed18aa2dde21956700 (diff)
Return std::unique_ptr member as const ref
Returning raw pointer has a risk that it may be stolen by std::shared_ptr in accident.
Diffstat (limited to 'src/DownloadContext.cc')
-rw-r--r--src/DownloadContext.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc
index 0a76bbf5..6591b3ea 100644
--- a/src/DownloadContext.cc
+++ b/src/DownloadContext.cc
@@ -156,12 +156,13 @@ void DownloadContext::setAttribute
attrs_[key] = std::move(value);
}
-ContextAttribute* DownloadContext::getAttribute(ContextAttributeType key)
+const std::unique_ptr<ContextAttribute>& DownloadContext::getAttribute
+(ContextAttributeType key)
{
assert(key < MAX_CTX_ATTR);
const std::unique_ptr<ContextAttribute>& attr = attrs_[key];
if(attr) {
- return attr.get();
+ return attr;
} else {
throw DL_ABORT_EX(fmt("No attribute named %s",
strContextAttributeType(key)));