mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix missing free on GrowableBitSet. init_new/init_temp for GrowableBitSet, LinkedList, List, HashMap, DString, ByteBuffer. Interface to_string renamed to_new_string. Change in allocator usage, malloc is now heap. Added new_array, new_zero_array, new, new_clear, clone. Concat => concat_new. string::printf => string::new_format, string::tprintf => string::tformat. "to_*" are now "to_new_*" and "to_temp_*". "from_*" is "new_from*"
This commit is contained in:
committed by
Christoffer Lerno
parent
69470b8738
commit
1e38ccdd2b
@@ -13,17 +13,22 @@ fn void CsvReader.init(&self, InStream* stream, String separator = ",")
|
||||
self.separator = separator;
|
||||
}
|
||||
|
||||
fn String[]! CsvReader.read_row(self, Allocator* using = mem::heap())
|
||||
fn String[]! CsvReader.read_new_row(self, Allocator* allocator = mem::heap())
|
||||
{
|
||||
@pool(using)
|
||||
return self.read_new_row_with_allocator(mem::temp()) @inline;
|
||||
}
|
||||
|
||||
fn String[]! CsvReader.read_new_row_with_allocator(self, Allocator* allocator = mem::heap())
|
||||
{
|
||||
@pool(allocator)
|
||||
{
|
||||
return io::treadline(self.stream).split(self.separator, .using = using);
|
||||
return io::treadline(self.stream).split(self.separator, .allocator = allocator);
|
||||
};
|
||||
}
|
||||
|
||||
fn String[]! CsvReader.tread_row(self)
|
||||
fn String[]! CsvReader.read_temp_row(self)
|
||||
{
|
||||
return self.read_row(mem::temp()) @inline;
|
||||
return self.read_new_row_with_allocator(mem::temp()) @inline;
|
||||
}
|
||||
|
||||
fn void! CsvReader.skip_row(self) @maydiscard
|
||||
@@ -45,13 +50,13 @@ macro CsvReader.@each_row(self, int rows = int.max; @body(String[] row))
|
||||
String[] parts;
|
||||
@pool()
|
||||
{
|
||||
String! s = stream.readline(mem::temp());
|
||||
String! s = stream.treadline();
|
||||
if (catch err = s)
|
||||
{
|
||||
if (err == IoError.EOF) return;
|
||||
return err?;
|
||||
}
|
||||
parts = s.split(sep, .using = mem);
|
||||
parts = s.split(sep, .allocator = mem);
|
||||
};
|
||||
@body(parts);
|
||||
};
|
||||
|
||||
@@ -15,9 +15,9 @@ fault JsonParsingError
|
||||
INVALID_NUMBER,
|
||||
}
|
||||
|
||||
fn Object*! parse(InStream* s, Allocator* using = mem::heap())
|
||||
fn Object*! parse(InStream* s, Allocator* allocator = mem::heap())
|
||||
{
|
||||
JsonContext context = { .last_string = dstring::new_with_capacity(64, using), .stream = s, .allocator = using };
|
||||
JsonContext context = { .last_string = dstring::new_with_capacity(64, allocator), .stream = s, .allocator = allocator };
|
||||
defer context.last_string.free();
|
||||
return parse_any(&context);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ fn JsonTokenType! lex_number(JsonContext *context, char c) @local
|
||||
{
|
||||
@pool()
|
||||
{
|
||||
DString t = dstring::tnew_with_capacity(32);
|
||||
DString t = dstring::temp_with_capacity(32);
|
||||
bool negate = c == '-';
|
||||
if (negate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user