mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Temp allocator now supports more than 2 in-flight stacks.
- Printing stacktrace uses its own temp allocator. - `@pool` no longer takes an argument. - `Allocator` interface removes `mark` and `reset`. - DynamicArenaAllocator has changed init function. - Added `BackedArenaAllocator` which is allocated to a fixed size, then allocates on the backing allocator and supports mark/reset.
This commit is contained in:
@@ -64,7 +64,7 @@ macro String? readline(Allocator allocator, stream = io::stdin())
|
||||
$endif
|
||||
|
||||
if (val == '\n') return "";
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
DString str = dstring::temp_with_capacity(256);
|
||||
if (val != '\r') str.append(val);
|
||||
|
||||
@@ -29,7 +29,7 @@ fn PathList? native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Al
|
||||
PathList list;
|
||||
list.init(allocator);
|
||||
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
WString result = dir.str_view().tconcat(`\*`).to_temp_wstring()!!;
|
||||
Win32_WIN32_FIND_DATAW find_data;
|
||||
@@ -39,7 +39,7 @@ fn PathList? native_ls(Path dir, bool no_dirs, bool no_symlinks, String mask, Al
|
||||
do
|
||||
{
|
||||
if (no_dirs && (find_data.dwFileAttributes & win32::FILE_ATTRIBUTE_DIRECTORY)) continue;
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
String filename = string::tfrom_wstring((WString)&find_data.cFileName)!;
|
||||
if (filename == ".." || filename == ".") continue;
|
||||
|
||||
@@ -11,7 +11,7 @@ fn Path? native_temp_directory(Allocator allocator) @if(!env::WIN32)
|
||||
return path::new(allocator, "/tmp");
|
||||
}
|
||||
|
||||
fn Path? native_temp_directory(Allocator allocator) @if(env::WIN32) => @pool(allocator)
|
||||
fn Path? native_temp_directory(Allocator allocator) @if(env::WIN32) => @pool()
|
||||
{
|
||||
Win32_DWORD len = win32::getTempPathW(0, null);
|
||||
if (!len) return io::GENERAL_ERROR?;
|
||||
|
||||
@@ -28,7 +28,7 @@ enum PathEnv
|
||||
|
||||
fn Path? cwd(Allocator allocator)
|
||||
{
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
return new(allocator, os::getcwd(tmem()));
|
||||
};
|
||||
@@ -153,7 +153,7 @@ fn Path? temp(String path, PathEnv path_env = DEFAULT_ENV)
|
||||
return new(tmem(), path, path_env);
|
||||
}
|
||||
|
||||
fn Path? from_win32_wstring(Allocator allocator, WString path) => @pool(allocator)
|
||||
fn Path? from_win32_wstring(Allocator allocator, WString path) => @pool()
|
||||
{
|
||||
return path::new(allocator, string::tfrom_wstring(path)!);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ fn Path? Path.append(self, Allocator allocator, String filename)
|
||||
if (!self.path_string.len) return new(allocator, filename, self.env)!;
|
||||
assert(!is_separator(self.path_string[^1], self.env));
|
||||
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
DString dstr = dstring::temp_with_capacity(self.path_string.len + 1 + filename.len);
|
||||
dstr.append(self.path_string);
|
||||
@@ -232,7 +232,7 @@ fn bool? Path.is_absolute(self)
|
||||
}
|
||||
|
||||
|
||||
fn Path? String.to_absolute_path(self, Allocator allocator) => @pool(allocator)
|
||||
fn Path? String.to_absolute_path(self, Allocator allocator) => @pool()
|
||||
{
|
||||
return temp(self).absolute(allocator);
|
||||
}
|
||||
@@ -247,14 +247,14 @@ fn Path? Path.absolute(self, Allocator allocator)
|
||||
if (self.is_absolute()!) return new(allocator, path_str, self.env);
|
||||
if (path_str == ".")
|
||||
{
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
String cwd = os::getcwd(tmem())!;
|
||||
return new(allocator, cwd, self.env);
|
||||
};
|
||||
}
|
||||
$if DEFAULT_ENV == WIN32:
|
||||
@pool(allocator)
|
||||
@pool()
|
||||
{
|
||||
const usz BUFFER_LEN = 4096;
|
||||
WString buffer = (WString)mem::talloc_array(Char16, BUFFER_LEN);
|
||||
@@ -268,7 +268,7 @@ fn Path? Path.absolute(self, Allocator allocator)
|
||||
$endif
|
||||
}
|
||||
|
||||
fn String? String.file_basename(self, Allocator allocator) => @pool(allocator)
|
||||
fn String? String.file_basename(self, Allocator allocator) => @pool()
|
||||
{
|
||||
return temp(self).basename().copy(allocator);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ fn String Path.basename(self)
|
||||
|
||||
fn String? String.path_tdirname(self) => self.path_dirname(tmem());
|
||||
|
||||
fn String? String.path_dirname(self, Allocator allocator) => @pool(allocator)
|
||||
fn String? String.path_dirname(self, Allocator allocator) => @pool()
|
||||
{
|
||||
return temp(self).dirname().copy(allocator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user