line = Brdstr(in, '\n', 1);
will give us a null-terminated string, but we don't want to flip the null and truncate the string, so to lazily avoid that we do: rlen = runestrlen(rstr);
rev = calloc(rlen+1, sizeof (Rune));
reverse(rstr, rev, rlen);
so we get the number of runes in the input, add 1 for the \0, then reverse the pre-\0 characters. tenshi% ns | grep 'bind' | grep '/bin'
bind /amd64/bin /bin
bind -a /rc/bin /bin
bind -b /usr/seh/bin/rc /bin
bind -b /usr/seh/bin/amd64 /bin
bind -a /sys/go/bin /bin
bind -a /usr/seh/go/bin /bin
tenshi%
[1] http://man.cat-v.org/9front/1/bind
This can get a little tricky when ownership comes in to play since you don't want to end up in a situation where (not in the above program's situation, but in general) the caller might pass out a value that never gets freed and you can easily create memory leaks.
You wouldn't want to do, for example:
Since smprint(2)'s return value was allocated and will need to be freed, but we have no way of doing that after the value is passed.
You'd need to do: