MCPcopy Create free account
hub / github.com/WheretIB/nullc / ExtendLinearTextBuffer

Method ExtendLinearTextBuffer

GUI/RichTextarea.cpp:810–833  ·  view source on GitHub ↗

Function is used to reserve space in linear text buffer

Source from the content-addressed store, hash-verified

808
809// Function is used to reserve space in linear text buffer
810void TextareaData::ExtendLinearTextBuffer()
811{
812 // Size that is needed is calculated by summing lengths of all lines
813 overallLength = 0;
814 AreaLine *curr = firstLine;
815 while(curr)
816 {
817 // AreaLine doesn't have the line endings (or any other special symbols)
818 // But GetAreaText() returns text with \r\n at the end, so we have to add
819 overallLength += curr->length + 2; // additional 2 bytes for \r\n
820 curr = curr->next;
821 }
822 if(overallLength >= areaTextSize)
823 {
824 // Reserve more than is needed
825 areaTextSize = overallLength + overallLength / 2;
826 delete[] areaText;
827 delete[] areaTextEx;
828 areaText = new char[areaTextSize];
829 areaTextEx = new char[areaTextSize];
830 memset(areaText, 0, areaTextSize);
831 memset(areaTextEx, 0, areaTextSize);
832 }
833}
834
835// Last edited position
836unsigned int maximumEnd;

Callers 2

BeginStyleUpdateMethod · 0.80
GetAreaTextMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected