Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpx/lua-cjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2016-04-13 12:12:18 +0300
committerMark Pulford <mark@kyne.com.au>2016-04-13 12:12:18 +0300
commit7eb09593cbddfa682f81f198734ce508b519fe00 (patch)
treea7f519fe7efdbd3f2c71e235b1f4e5855e3cac5c /strbuf.c
parent1740e529ca7a9c249b7c8aaeec7336d8000bd192 (diff)
Fix build with g++
- Add explicit casts for functions returning void* - Rename "try" variable to avoid reserved C++ keyword
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/strbuf.c b/strbuf.c
index f0f7f4b..ac779e4 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -58,7 +58,7 @@ void strbuf_init(strbuf_t *s, int len)
s->reallocs = 0;
s->debug = 0;
- s->buf = malloc(size);
+ s->buf = (char *)malloc(size);
if (!s->buf)
die("Out of memory");
@@ -69,7 +69,7 @@ strbuf_t *strbuf_new(int len)
{
strbuf_t *s;
- s = malloc(sizeof(strbuf_t));
+ s = (strbuf_t*)malloc(sizeof(strbuf_t));
if (!s)
die("Out of memory");
@@ -173,7 +173,7 @@ void strbuf_resize(strbuf_t *s, int len)
}
s->size = newsize;
- s->buf = realloc(s->buf, s->size);
+ s->buf = (char *)realloc(s->buf, s->size);
if (!s->buf)
die("Out of memory");
s->reallocs++;
@@ -221,12 +221,13 @@ void strbuf_append_fmt(strbuf_t *s, int len, const char *fmt, ...)
void strbuf_append_fmt_retry(strbuf_t *s, const char *fmt, ...)
{
va_list arg;
- int fmt_len, try;
+ int fmt_len;
int empty_len;
+ int t;
/* If the first attempt to append fails, resize the buffer appropriately
* and try again */
- for (try = 0; ; try++) {
+ for (t = 0; ; t++) {
va_start(arg, fmt);
/* Append the new formatted string */
/* fmt_len is the length of the string required, excluding the
@@ -238,7 +239,7 @@ void strbuf_append_fmt_retry(strbuf_t *s, const char *fmt, ...)
if (fmt_len <= empty_len)
break; /* SUCCESS */
- if (try > 0)
+ if (t > 0)
die("BUG: length of formatted string changed");
strbuf_resize(s, s->length + fmt_len);