瀏覽代碼

Clean up filepath.lazy_buffer memory leak

gingerBill 4 年之前
父節點
當前提交
ea6b222430
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      core/path/filepath/path.odin

+ 7 - 1
core/path/filepath/path.odin

@@ -169,7 +169,7 @@ clean :: proc(path: string, allocator := context.allocator) -> string {
 	s := lazy_buffer_string(out);
 	s := lazy_buffer_string(out);
 	cleaned, new_allocation := from_slash(s);
 	cleaned, new_allocation := from_slash(s);
 	if new_allocation {
 	if new_allocation {
-		delete(s);
+		lazy_buffer_destroy(s);
 	}
 	}
 	return cleaned;
 	return cleaned;
 }
 }
@@ -395,3 +395,9 @@ lazy_buffer_string :: proc(lb: ^Lazy_Buffer) -> string {
 	copy(z[len(x):], y);
 	copy(z[len(x):], y);
 	return string(z);
 	return string(z);
 }
 }
+@(private)
+lazy_buffer_destroy :: proc(lb: ^Lazy_Buffer) {
+	delete(lb.b);
+	delete(lb);
+	lb^ = {};
+}