aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PerLine.cxx
diff options
context:
space:
mode:
authormitchell <unknown>2020-01-05 21:22:02 -0500
committermitchell <unknown>2020-01-05 21:22:02 -0500
commit60e87889d6438e386acf58c3967fb874af9aae82 (patch)
tree9c5c2660c59aff04ddedea19fa03fd271f8bba5c /src/PerLine.cxx
parentdbb7374c185718655dd77c294eb281e8b93c538e (diff)
downloadscintilla-mirror-60e87889d6438e386acf58c3967fb874af9aae82.tar.gz
Added Sci::make_unique() and Sci::size() for better compatibility with the default branch.
std::make_unique() is c++14 and std::size() is c++17.
Diffstat (limited to 'src/PerLine.cxx')
-rw-r--r--src/PerLine.cxx25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index d81f46d3b..e67426ae7 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -118,7 +118,7 @@ Sci::Line LineMarkers::LineFromHandle(int markerHandle) {
void LineMarkers::MergeMarkers(Sci::Line line) {
if (markers[line + 1]) {
if (!markers[line])
- markers[line].reset(new MarkerHandleSet);
+ markers[line] = Sci::make_unique<MarkerHandleSet>();
markers[line]->CombineWith(markers[line + 1].get());
markers[line + 1].reset();
}
@@ -154,7 +154,7 @@ int LineMarkers::AddMark(Sci::Line line, int markerNum, Sci::Line lines) {
}
if (!markers[line]) {
// Need new structure to hold marker handle
- markers[line].reset(new MarkerHandleSet());
+ markers[line] = Sci::make_unique<MarkerHandleSet>();
}
markers[line]->InsertHandle(handleCurrent, markerNum);
@@ -357,17 +357,16 @@ const unsigned char *LineAnnotation::Styles(Sci::Line line) const {
return nullptr;
}
-static char *AllocateAnnotation(int length, int style) {
+static std::unique_ptr<char[]>AllocateAnnotation(int length, int style) {
const size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0);
- char *ret = new char[len]();
- return ret;
+ return Sci::make_unique<char[]>(len);
}
void LineAnnotation::SetText(Sci::Line line, const char *text) {
if (text && (line >= 0)) {
annotations.EnsureLength(line+1);
const int style = Style(line);
- annotations[line].reset(AllocateAnnotation(static_cast<int>(strlen(text)), style));
+ annotations[line] = AllocateAnnotation(static_cast<int>(strlen(text)), style);
char *pa = annotations[line].get();
assert(pa);
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(pa);
@@ -389,7 +388,7 @@ void LineAnnotation::ClearAll() {
void LineAnnotation::SetStyle(Sci::Line line, int style) {
annotations.EnsureLength(line+1);
if (!annotations[line]) {
- annotations[line].reset(AllocateAnnotation(0, style));
+ annotations[line] = AllocateAnnotation(0, style);
}
reinterpret_cast<AnnotationHeader *>(annotations[line].get())->style = static_cast<short>(style);
}
@@ -398,16 +397,16 @@ void LineAnnotation::SetStyles(Sci::Line line, const unsigned char *styles) {
if (line >= 0) {
annotations.EnsureLength(line+1);
if (!annotations[line]) {
- annotations[line].reset(AllocateAnnotation(0, IndividualStyles));
+ annotations[line] = AllocateAnnotation(0, IndividualStyles);
} else {
const AnnotationHeader *pahSource = reinterpret_cast<AnnotationHeader *>(annotations[line].get());
if (pahSource->style != IndividualStyles) {
- char *allocation = AllocateAnnotation(pahSource->length, IndividualStyles);
- AnnotationHeader *pahAlloc = reinterpret_cast<AnnotationHeader *>(allocation);
+ std::unique_ptr<char[]>allocation = AllocateAnnotation(pahSource->length, IndividualStyles);
+ AnnotationHeader *pahAlloc = reinterpret_cast<AnnotationHeader *>(allocation.get());
pahAlloc->length = pahSource->length;
pahAlloc->lines = pahSource->lines;
- memcpy(allocation + sizeof(AnnotationHeader), annotations[line].get() + sizeof(AnnotationHeader), pahSource->length);
- annotations[line].reset(allocation);
+ memcpy(allocation.get() + sizeof(AnnotationHeader), annotations[line].get() + sizeof(AnnotationHeader), pahSource->length);
+ annotations[line] = std::move(allocation);
}
}
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(annotations[line].get());
@@ -465,7 +464,7 @@ bool LineTabstops::ClearTabstops(Sci::Line line) {
bool LineTabstops::AddTabstop(Sci::Line line, int x) {
tabstops.EnsureLength(line + 1);
if (!tabstops[line]) {
- tabstops[line].reset(new TabstopList());
+ tabstops[line] = Sci::make_unique<TabstopList>();
}
TabstopList *tl = tabstops[line].get();