summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-16 13:18:31 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-16 13:18:31 -0700
commit9ae4975fc049de433ad8e2399c391d207208233a (patch)
tree930bb6f38b8d3bba16dc4ced81406a9271f81f54 /src/buffer.c
parent0c439ac3ab8c59a90277daad0c2ece5e937a6528 (diff)
astyle formatting changes.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 7d16af8..e07fba6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -29,18 +29,20 @@ void cmark_strbuf_init(cmark_strbuf *buf, bufsize_t initial_size)
cmark_strbuf_grow(buf, initial_size);
}
-void cmark_strbuf_overflow_err() {
+void cmark_strbuf_overflow_err()
+{
fprintf(stderr, "String buffer overflow");
abort();
}
static inline void
-S_strbuf_grow_by(cmark_strbuf *buf, size_t add) {
+S_strbuf_grow_by(cmark_strbuf *buf, size_t add)
+{
size_t target_size = (size_t)buf->size + add;
if (target_size < add /* Integer overflow. */
|| target_size > BUFSIZE_MAX /* Truncation overflow. */
- ) {
+ ) {
cmark_strbuf_overflow_err();
return; /* unreachable */
}
@@ -74,7 +76,7 @@ void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size)
if (new_size < (size_t)target_size /* Integer overflow. */
|| new_size > BUFSIZE_MAX /* Truncation overflow. */
- ) {
+ ) {
if (target_size >= BUFSIZE_MAX) {
/* No space for terminating null byte. */
cmark_strbuf_overflow_err();
@@ -160,7 +162,7 @@ void cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, bufsize_t le
void cmark_strbuf_puts(cmark_strbuf *buf, const char *string)
{
cmark_strbuf_put(buf, (const unsigned char *)string,
- cmark_strbuf_safe_strlen(string));
+ cmark_strbuf_safe_strlen(string));
}
void cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap)
@@ -175,10 +177,10 @@ void cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap)
va_copy(args, ap);
int len = vsnprintf(
- (char *)buf->ptr + buf->size,
- buf->asize - buf->size,
- format, args
- );
+ (char *)buf->ptr + buf->size,
+ buf->asize - buf->size,
+ format, args
+ );
#ifndef HAVE_C99_SNPRINTF
// Assume we're on Windows.
if (len < 0) {