summaryrefslogtreecommitdiffstats
path: root/membuffer.c
AgeCommit message (Collapse)Author
2014-04-05Use helper function to write decimal numbersGravatar Gehad
Never ever use '%f' to write floating point data to a file. The stupid locale handling creates useless comma-infested output in some locales. Instead use one of our clever helper functions to do the right thing. Original patch by Gehad, modified by Linus to be a little more generic. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-08Fix totally broken put_vformat() implementationGravatar Linus Torvalds
I'm ashamed. put_vbuffer() worked perfectly fine for the normal case when everything fit in our simple buffer on-stack, but the fallback case was broken in so many ways that I'm just going to go sit in a corner and cry myself to sleep. And dammit, I _knew_ how to do it right. I knew you had to do a "va_copy()" and couldn't just keep re-using 'args'. I've done this before. But I half-arsed it, and nobody ever noticed, because you wouldn't do C style format strings for big strings. "128 bytes is enough for everybody". And as penance for this idiocy, I just spent too much time trying to figure out what was wrong in my git loading code when my debug printouts caused SIGSEGV's. Sigh. Anyway, now it should hopefully be correct, and the code is smarter about things too, not having that extra buffer since we already *have* a buffer in the "struct membuffer" we are working with. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07Don't have the put_something() functions return successGravatar Dirk Hohndel
We didn't use the return value anywhere. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07Add C string helper to membuffer interfaceGravatar Linus Torvalds
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>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
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>
2014-02-10Clean up membuffer internal structure names, add strip functionGravatar Linus Torvalds
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>
2014-01-16Save XML files into a memory buffer rather than directly into a fileGravatar Linus Torvalds
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>