mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
This commit is contained in:
parent
50820105a1
commit
721328ef58
4 changed files with 126 additions and 35 deletions
|
@ -16,6 +16,17 @@ pub fn new_builder(initial_size int) Builder {
|
|||
return res
|
||||
}
|
||||
|
||||
// reuse_as_plain_u8_array allows using the Builder instance as a plain []u8 return value.
|
||||
// It is useful, when you have accumulated data in the builder, that you want to
|
||||
// pass/access as []u8 later, without copying or freeing the buffer.
|
||||
// NB: you *should NOT use* the string builder instance after calling this method.
|
||||
// Use only the return value after calling this method.
|
||||
[unsafe]
|
||||
pub fn (mut b Builder) reuse_as_plain_u8_array() []u8 {
|
||||
unsafe { b.flags.clear(.noslices) }
|
||||
return *b
|
||||
}
|
||||
|
||||
// write_ptr writes `len` bytes provided byteptr to the accumulated buffer
|
||||
[unsafe]
|
||||
pub fn (mut b Builder) write_ptr(ptr &u8, len int) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue