| 804 | |
| 805 | |
| 806 | inline alloc_slice alloc_slice::nullPaddedString(pure_slice str) { |
| 807 | // Leave a trailing null byte after the end, so it can be used as a C string |
| 808 | alloc_slice a(str.size + 1); |
| 809 | str.copyTo((void*)a.buf); |
| 810 | ((char*)a.buf)[str.size] = '\0'; |
| 811 | a.shorten(str.size); // the null byte is not part of the slice |
| 812 | return a; |
| 813 | } |
| 814 | |
| 815 | |
| 816 | __hot |