summaryrefslogtreecommitdiff
path: root/printbuf.c
diff options
context:
space:
mode:
authorMichael Clark <michael@metaparadigm.com>2009-04-27 08:16:58 +0000
committerMichael Clark <michael@metaparadigm.com>2009-04-27 08:16:58 +0000
commit95f55a761c9ad640cbad9f84627575e7b5a76fe1 (patch)
tree7959d0ecc06c7f64d2014a2b36aa03cf17c0e86e /printbuf.c
parentaaec1ef3c542accb118af48c09edc7e07675671a (diff)
optimizations to json_tokener_parse_ex(), printbuf_memappend()
-- Brent Miller, bdmiller at yahoo dash inc dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@34 327403b1-1117-474d-bef2-5cb71233fd97
Diffstat (limited to 'printbuf.c')
-rw-r--r--printbuf.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/printbuf.c b/printbuf.c
index a2182f4..a9c711c 100644
--- a/printbuf.c
+++ b/printbuf.c
@@ -7,6 +7,10 @@
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See COPYING for details.
*
+ *
+ * Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
+ * The copyrights to the contents of this file are licensed under the MIT License
+ * (http://www.opensource.org/licenses/mit-license.php)
*/
#include "config.h"
@@ -118,16 +122,15 @@ int sprintbuf(struct printbuf *p, const char *msg, ...)
if output is truncated whereas some return the number of bytes that
would have been writen - this code handles both cases. */
if(size == -1 || size > 127) {
- int ret;
va_start(ap, msg);
- size = vasprintf(&t, msg, ap);
+ if((size = vasprintf(&t, msg, ap)) == -1) return -1;
va_end(ap);
- if(size == -1) return -1;
- ret = printbuf_memappend(p, t, size);
+ printbuf_memappend(p, t, size);
free(t);
- return ret;
+ return size;
} else {
- return printbuf_memappend(p, buf, size);
+ printbuf_memappend(p, buf, size);
+ return size;
}
}