I don't know why I didn't do this from the beginning. We often build up
a membuffer and then want to use it as a C string. You could do it by
hand by adding the zero byte at the end, but that's just annoying.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The "size" member was confusing - it's the size of the allocation, not
the size of the current string. The size of the current string is the
member called "used".
This naming makes perfect sense for the internal implementation, but
it's confusing to users who actually do want to get the size of the
resulting string at the end.
So rename the fields to "alloc" and "len" - which is pretty clear.
This also adds a helper function to strip whitespace from the end:
"strip_mb()".
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This introduces a "struct membuffer" abstraction that you can write
things into, and makes the XML saving code write to the memory buffer
rather than a file.
The UDDF export already really wanted this: it used to write to a file,
only to then read that file back into memory, delete the file, and then
*rewrite* the file after doing the magic xslt transform.
But the longer-term reason for this is that I want to try to write other
formats, and I want to try to share most helpers. And those other
formats will need this memory buffer model.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>