Module: check_mk
Branch: master
Commit: e09f9016a72aeb87f901414edd549a6c86148aea
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e09f9016a72aeb…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jul 20 14:02:51 2016 +0200
Fetched Livestatus from upstream.
---
livestatus/src/DownCommColumn.cc | 4 ++--
livestatus/src/DowntimeOrComment.cc | 9 +++------
livestatus/src/DowntimeOrComment.h | 5 +++--
livestatus/src/TableDownComm.cc | 10 +++++-----
4 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/livestatus/src/DownCommColumn.cc b/livestatus/src/DownCommColumn.cc
index abcbcec..aaef2f6 100644
--- a/livestatus/src/DownCommColumn.cc
+++ b/livestatus/src/DownCommColumn.cc
@@ -47,8 +47,8 @@ void DownCommColumn::output(void *row, Renderer::Row &r,
if (_with_info) {
Renderer::Sublist s(l);
s.outputUnsignedLong(id);
- s.outputString(dt->_author_name);
- s.outputString(dt->_comment);
+ s.outputCPPString(dt->_author_name);
+ s.outputCPPString(dt->_comment);
if (_with_extra_info && !_is_downtime) {
s.outputInteger(
static_cast<Comment *>(dt)->_entry_type);
diff --git a/livestatus/src/DowntimeOrComment.cc b/livestatus/src/DowntimeOrComment.cc
index 583fb35..30435f1 100644
--- a/livestatus/src/DowntimeOrComment.cc
+++ b/livestatus/src/DowntimeOrComment.cc
@@ -30,8 +30,8 @@ DowntimeOrComment::DowntimeOrComment(nebstruct_downtime_struct *dt,
unsigned long id)
: _type(dt->downtime_type)
, _entry_time(dt->entry_time)
- , _author_name(strdup(dt->author_name))
- , _comment(strdup(dt->comment_data))
+ , _author_name(dt->author_name)
+ , _comment(dt->comment_data)
, _id(id) {
_host = find_host(dt->host_name);
if (dt->service_description != nullptr) {
@@ -43,10 +43,7 @@ DowntimeOrComment::DowntimeOrComment(nebstruct_downtime_struct *dt,
}
}
-DowntimeOrComment::~DowntimeOrComment() {
- free(_author_name);
- free(_comment);
-}
+DowntimeOrComment::~DowntimeOrComment() = default;
Downtime::Downtime(nebstruct_downtime_struct *dt)
: DowntimeOrComment(dt, dt->downtime_id)
diff --git a/livestatus/src/DowntimeOrComment.h b/livestatus/src/DowntimeOrComment.h
index 7f5a065..6c7ea11 100644
--- a/livestatus/src/DowntimeOrComment.h
+++ b/livestatus/src/DowntimeOrComment.h
@@ -27,6 +27,7 @@
#include "config.h" // IWYU pragma: keep
#include <time.h>
+#include <string>
#include "nagios.h" // IWYU pragma: keep
/* The structs for downtime and comment are so similar, that
@@ -84,8 +85,8 @@ public:
host *_host;
service *_service;
time_t _entry_time;
- char *_author_name;
- char *_comment;
+ std::string _author_name;
+ std::string _comment;
unsigned long _id;
int _is_service;
diff --git a/livestatus/src/TableDownComm.cc b/livestatus/src/TableDownComm.cc
index 0bd8281..2504050 100644
--- a/livestatus/src/TableDownComm.cc
+++ b/livestatus/src/TableDownComm.cc
@@ -28,7 +28,7 @@
#include "DowntimeOrComment.h"
#include "DowntimesOrComments.h" // IWYU pragma: keep
#include "OffsetIntColumn.h"
-#include "OffsetStringColumn.h"
+#include "OffsetSStringColumn.h"
#include "OffsetTimeColumn.h"
#include "Query.h"
#include "TableHosts.h"
@@ -43,15 +43,15 @@ TableDownComm::TableDownComm(bool is_downtime,
: _is_downtime(is_downtime)
, _holder(is_downtime ? downtimes_holder : comments_holder) {
DowntimeOrComment *ref = nullptr;
- addColumn(new OffsetStringColumn(
+ addColumn(new OffsetSStringColumn(
"author", is_downtime ? "The contact that scheduled the
downtime"
: "The contact that entered the comment",
reinterpret_cast<char *>(&(ref->_author_name)) -
reinterpret_cast<char *>(ref)));
addColumn(
- new OffsetStringColumn("comment", "A comment text",
- reinterpret_cast<char *>(&(ref->_comment)) -
- reinterpret_cast<char *>(ref)));
+ new OffsetSStringColumn("comment", "A comment text",
+ reinterpret_cast<char *>(&(ref->_comment))
-
+ reinterpret_cast<char *>(ref)));
addColumn(new OffsetIntColumn(
"id", is_downtime ? "The id of the downtime" : "The id
of the comment",
reinterpret_cast<char *>(&(ref->_id)) - reinterpret_cast<char
*>(ref)));