| 1 | fn abc() string { |
| 2 | unsafe { |
| 3 | mut fullpath := vcalloc(4) |
| 4 | fullpath[0] = `a` |
| 5 | fullpath[1] = `b` |
| 6 | fullpath[2] = `c` |
| 7 | fullpath[3] = 0 |
| 8 | return fullpath.vstring() |
| 9 | } |
| 10 | return '' |
| 11 | } |
| 12 | |
| 13 | fn def() string { |
| 14 | unsafe { |
| 15 | mut fullpath := vcalloc(4) |
| 16 | fullpath[0] = `a` |
| 17 | fullpath[1] = `b` |
| 18 | fullpath[2] = `c` |
| 19 | fullpath[3] = 0 |
| 20 | return fullpath.vstring_with_len(3) |
| 21 | } |
| 22 | return '' |
| 23 | } |
| 24 | |
| 25 | fn main() { |
| 26 | assert 'abc' == abc() |
| 27 | assert 'abc' == def() |
| 28 | abc_str1 := ptr_str(abc().str) |
| 29 | abc_str2 := ptr_str(abc().str) |
| 30 | println('abc_str1: ${abc_str1}') |
| 31 | println('abc_str2: ${abc_str2}') |
| 32 | assert abc_str1 != abc_str2 |
| 33 | } |
| 34 | |