Fix memory corruption
This commit is contained in:
@@ -1034,8 +1034,11 @@ inline TempArena GetScratch(Arena *c1 = NULL, Arena *c2 = NULL) {
|
|||||||
struct Scratch {
|
struct Scratch {
|
||||||
TempArena checkpoint;
|
TempArena checkpoint;
|
||||||
Scratch() { this->checkpoint = GetScratch(); }
|
Scratch() { this->checkpoint = GetScratch(); }
|
||||||
|
|
||||||
Scratch(Arena *conflict) { this->checkpoint = GetScratch(conflict); }
|
Scratch(Arena *conflict) { this->checkpoint = GetScratch(conflict); }
|
||||||
Scratch(Arena *c1, Arena *c2) { this->checkpoint = GetScratch(c1, c2); }
|
Scratch(Arena *c1, Arena *c2) { this->checkpoint = GetScratch(c1, c2); }
|
||||||
|
Scratch(Allocator conflict) { this->checkpoint = GetScratch((Arena *)conflict.object); }
|
||||||
|
Scratch(Allocator c1, Allocator c2) { this->checkpoint = GetScratch((Arena *)c1.object, (Arena *)c2.object); }
|
||||||
~Scratch() { EndTemp(checkpoint); }
|
~Scratch() { EndTemp(checkpoint); }
|
||||||
operator Arena *() { return checkpoint.arena; }
|
operator Arena *() { return checkpoint.arena; }
|
||||||
operator Allocator() { return *checkpoint.arena; }
|
operator Allocator() { return *checkpoint.arena; }
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ String GetExePath(Allocator allocator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String GetExeDir(Allocator allocator) {
|
String GetExeDir(Allocator allocator) {
|
||||||
Scratch scratch;
|
Scratch scratch((Arena *)allocator.object);
|
||||||
String path = GetExePath(scratch);
|
String path = GetExePath(scratch);
|
||||||
path = ChopLastSlash(path);
|
path = ChopLastSlash(path);
|
||||||
path = Copy(allocator, path);
|
path = Copy(allocator, path);
|
||||||
|
|||||||
@@ -217,20 +217,20 @@ void MergeCarets(View *view, Range *mouse_selection_anchor) {
|
|||||||
Swap(&view->carets[first_caret_index], &view->carets[0]);
|
Swap(&view->carets[first_caret_index], &view->carets[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
String DebugViewList() {
|
String DebugViewList(Allocator allocator) {
|
||||||
Scratch scratch;
|
Scratch scratch((Arena *)allocator.object);
|
||||||
Array<String> strings = {scratch};
|
Array<String> strings = {scratch};
|
||||||
For(Views) {
|
For(Views) {
|
||||||
Buffer *buffer = GetBuffer(it.active_buffer);
|
Buffer *buffer = GetBuffer(it.active_buffer);
|
||||||
String string = Format(scratch, "view = %lld buffer = %lld name = %.*s", (long long)it.id.id, (long long)buffer->id.id, FmtString(buffer->name));
|
String string = Format(scratch, "view = %lld buffer = %lld name = %.*s", (long long)it.id.id, (long long)buffer->id.id, FmtString(buffer->name));
|
||||||
Add(&strings, string);
|
Add(&strings, string);
|
||||||
}
|
}
|
||||||
String result = Merge(scratch, strings, "\n");
|
String result = Merge(allocator, strings, "\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String DebugWindowList() {
|
String DebugWindowList(Allocator allocator) {
|
||||||
Scratch scratch;
|
Scratch scratch((Arena *)allocator.object);
|
||||||
Array<String> strings = {scratch};
|
Array<String> strings = {scratch};
|
||||||
For(Windows) {
|
For(Windows) {
|
||||||
View *view = GetActiveView(&it);
|
View *view = GetActiveView(&it);
|
||||||
@@ -244,7 +244,7 @@ String DebugWindowList() {
|
|||||||
Add(&strings, child_string);
|
Add(&strings, child_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String result = Merge(scratch, strings, "\n");
|
String result = Merge(allocator, strings, "\n");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,11 +264,11 @@ void ReplaceDebugData() {
|
|||||||
String16 string = ToString16(scratch, s);
|
String16 string = ToString16(scratch, s);
|
||||||
ReplaceText(buffer, GetRange(*buffer), string);
|
ReplaceText(buffer, GetRange(*buffer), string);
|
||||||
|
|
||||||
// String view_list = DebugViewList();
|
String view_list = DebugViewList(scratch);
|
||||||
// Append(buffer, ToString16(scratch, view_list));
|
Append(buffer, ToString16(scratch, view_list));
|
||||||
|
|
||||||
// String window_list = DebugWindowList();
|
String window_list = DebugWindowList(scratch);
|
||||||
// Append(buffer, ToString16(scratch, window_list));
|
Append(buffer, ToString16(scratch, window_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplaceInfobarData() {
|
void ReplaceInfobarData() {
|
||||||
@@ -292,7 +292,7 @@ void ReplaceInfobarData() {
|
|||||||
ReplaceText(buffer, GetEndAsRange(*buffer), L" |");
|
ReplaceText(buffer, GetEndAsRange(*buffer), L" |");
|
||||||
}
|
}
|
||||||
|
|
||||||
String s = Format(scratch, "Line %lld Column %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll);
|
String s = Format(scratch, " Line %lld Column %lld", (long long)xy.line + 1ll, (long long)xy.col + 1ll);
|
||||||
String16 string = ToString16(scratch, s);
|
String16 string = ToString16(scratch, s);
|
||||||
ReplaceText(buffer, replace_range, string);
|
ReplaceText(buffer, replace_range, string);
|
||||||
Command_SelectRangeOneCursor(view, {});
|
Command_SelectRangeOneCursor(view, {});
|
||||||
|
|||||||
@@ -10,8 +10,9 @@
|
|||||||
- open "asd/asd/asd/asd"
|
- open "asd/asd/asd/asd"
|
||||||
- word completion
|
- word completion
|
||||||
- Colored strings
|
- Colored strings
|
||||||
- open project files in folder and only show open views in Ctrl+P
|
|
||||||
- Set scroll centered
|
- Set scroll centered
|
||||||
|
- file lister
|
||||||
|
- Remove view children, replace with view history
|
||||||
|
|
||||||
- font cache and on demand unicode loads
|
- font cache and on demand unicode loads
|
||||||
|
|
||||||
|
|||||||
@@ -120,14 +120,14 @@ void LayoutWindows() {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex * 0.5));
|
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex * 0.5));
|
||||||
Windows[i].document_rect = Windows[i].total_rect;
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, FontCharSpacing);
|
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)(10.f * DPIScale));
|
||||||
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex));
|
Windows[i].total_rect = CutLeft(&screen_rect, (Int)((double)sizex));
|
||||||
Windows[i].document_rect = Windows[i].total_rect;
|
Windows[i].document_rect = Windows[i].total_rect;
|
||||||
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, FontCharSpacing);
|
if (Windows[i].draw_scrollbar) Windows[i].scrollbar_rect = CutRight(&Windows[i].document_rect, (Int)(10.f * DPIScale));
|
||||||
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
if (Windows[i].draw_line_numbers) Windows[i].line_numbers_rect = CutLeft(&Windows[i].document_rect, (Int)line_numbers_size);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user