Clean up membuffer internal structure names, add strip function

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 commit is contained in:
Linus Torvalds 2014-02-09 09:40:49 -08:00 committed by Dirk Hohndel
parent 22f66501ac
commit 77da20196f
3 changed files with 28 additions and 11 deletions

View file

@ -610,7 +610,7 @@ void export_dives_uddf(const char *filename, const bool selected)
* transform it to UDDF format, finally dumping
* the XML into a character buffer.
*/
doc = xmlReadMemory(buf.buffer, buf.used, "divelog", NULL, 0);
doc = xmlReadMemory(buf.buffer, buf.len, "divelog", NULL, 0);
free_buffer(&buf);
if (!doc) {
fprintf(stderr, "Failed to read XML memory\n");