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
This commit is contained in:
Albrecht Schlosser 2016-12-05 17:03:29 +00:00
parent 0701204518
commit b6bd386231
2 changed files with 4 additions and 2 deletions

View File

@ -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

View File

@ -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;
}
}
/*