From b6bd386231b9c8a385f1402bed44514f8dc02ffa Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 5 Dec 2016 17:03:29 +0000 Subject: Fl_Text_Buffer constructor: fix "requestedSize ignored in mGapEnd". mGapEnd should reflect the total allocated size after the constructor is executed, i.e. the text buffer is empty. This was not the case. See thread "Fl_Text_Buffer constructor bug" (2016-12-05) in fltk.general. The bug was harmless, but the pre-allocation did not work as expected, i.e. the pre-allocated buffer size was allocated but effectively ignored later. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12134 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ src/Fl_Text_Buffer.cxx | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index adb05fb14..18f7bd153 100644 --- a/CHANGES +++ b/CHANGES @@ -42,6 +42,8 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017 Bug Fixes - (add here) + - Fix ignored buffer pre-allocation (requestedSize) in Fl_Text_Buffer. + See fltk.general "Fl_Text_Buffer constructor bug" on Dec 5, 2016. - Fix build with configure --enable-cairo --enable-cairoext, see this report in fltk.general: https://groups.google.com/forum/#!topic/fltkgeneral/x80qQ6wt0s4 diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx index c4a935a81..9efcd6609 100644 --- a/src/Fl_Text_Buffer.cxx +++ b/src/Fl_Text_Buffer.cxx @@ -108,7 +108,7 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize) mPreferredGapSize = preferredGapSize; mBuf = (char *) malloc(requestedSize + mPreferredGapSize); mGapStart = 0; - mGapEnd = mPreferredGapSize; + mGapEnd = requestedSize + mPreferredGapSize; mTabDist = 8; mPrimary.mSelected = 0; mPrimary.mStart = mPrimary.mEnd = 0; @@ -1421,7 +1421,7 @@ void Fl_Text_Buffer::reallocate_with_gap(int newGapStart, int newGapLen) mBuf = newBuf; mGapStart = newGapStart; mGapEnd = newGapEnd; - } +} /* -- cgit v1.2.3