summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-02-14 11:26:45 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-02-14 11:26:45 +0300
commit246ad410e58674598ceb50fbfd39746f2e9902e9 (patch)
tree6cd7bf2a3afee88601152f217c55602b484c323b /cord
parentb2b0d2722ce8ba4471697f7296b3efda183b2911 (diff)
downloadbdwgc-246ad410e58674598ceb50fbfd39746f2e9902e9.tar.gz
Convert cord source files to valid C++ code
Issue #206 (bdwgc). * cord/cordbscs.c (Concatenation, Function, Generic): Define struct outside union (i.e. the union just uses them). * cord/cordbscs.c (CORD_cat_char_star, CORD_from_fn_inner, CORD_substr_checked): Cast GC_MALLOC_ATOMIC() result to char*. * cord/cordprnt.c (CORD_vsprintf): Likewise. * cord/cordxtra.c (CORD_cat_char, CORD_to_char_star, CORD_from_char_star, CORD_ec_flush_buf): Likewise. * cord/cordbscs.c (CORD_substr_checked): Remove register keyword for "result" local variable.
Diffstat (limited to 'cord')
-rw-r--r--cord/cordbscs.c24
-rw-r--r--cord/cordprnt.c5
-rw-r--r--cord/cordxtra.c8
3 files changed, 22 insertions, 15 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c
index 032c4fba..a5764784 100644
--- a/cord/cordbscs.c
+++ b/cord/cordbscs.c
@@ -42,7 +42,6 @@ oom_fn CORD_oom_fn = (oom_fn) 0;
typedef unsigned long word;
-typedef union {
struct Concatenation {
char null;
char header;
@@ -54,7 +53,8 @@ typedef union {
word len;
CORD left; /* length(left) > 0 */
CORD right; /* length(right) > 0 */
- } concatenation;
+ };
+
struct Function {
char null;
char header;
@@ -63,14 +63,20 @@ typedef union {
word len;
CORD_fn fn;
void * client_data;
- } function;
+ };
+
struct Generic {
char null;
char header;
char depth;
char left_len;
word len;
- } generic;
+ };
+
+typedef union {
+ struct Concatenation concatenation;
+ struct Function function;
+ struct Generic generic;
char string[1];
} CordRep;
@@ -161,7 +167,7 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny)
lenx = strlen(x);
result_len = lenx + leny;
if (result_len <= SHORT_LIMIT) {
- register char * result = GC_MALLOC_ATOMIC(result_len+1);
+ char * result = (char *)GC_MALLOC_ATOMIC(result_len + 1);
if (result == 0) OUT_OF_MEMORY;
memcpy(result, x, lenx);
@@ -193,7 +199,7 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny)
}
result_len = right_len + leny; /* length of new_right */
if (result_len <= SHORT_LIMIT) {
- new_right = GC_MALLOC_ATOMIC(result_len + 1);
+ new_right = (char *)GC_MALLOC_ATOMIC(result_len + 1);
if (new_right == 0) OUT_OF_MEMORY;
memcpy(new_right, right, right_len);
memcpy(new_right + right_len, y, leny);
@@ -293,7 +299,7 @@ static CordRep *CORD_from_fn_inner(CORD_fn fn, void * client_data, size_t len)
buf[i] = c;
}
- result = GC_MALLOC_ATOMIC(len+1);
+ result = (char *)GC_MALLOC_ATOMIC(len + 1);
if (result == 0) OUT_OF_MEMORY;
memcpy(result, buf, len);
result[len] = '\0';
@@ -378,7 +384,7 @@ CORD CORD_substr_checked(CORD x, size_t i, size_t n)
if (n > SUBSTR_LIMIT) {
return(CORD_substr_closure(x, i, n, CORD_index_access_fn));
} else {
- register char * result = GC_MALLOC_ATOMIC(n+1);
+ char * result = (char *)GC_MALLOC_ATOMIC(n + 1);
if (result == 0) OUT_OF_MEMORY;
strncpy(result, x+i, n);
@@ -448,7 +454,7 @@ CORD CORD_substr_checked(CORD x, size_t i, size_t n)
}
*p++ = c;
}
- result = GC_MALLOC_ATOMIC(n+1);
+ result = (char *)GC_MALLOC_ATOMIC(n + 1);
if (result == 0) OUT_OF_MEMORY;
memcpy(result, buf, n);
result[n] = '\0';
diff --git a/cord/cordprnt.c b/cord/cordprnt.c
index 051e8930..80454a0e 100644
--- a/cord/cordprnt.c
+++ b/cord/cordprnt.c
@@ -247,7 +247,8 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
len = (unsigned)prec;
}
if (width != NONE && len < (size_t)width) {
- char * blanks = GC_MALLOC_ATOMIC(width-len+1);
+ char * blanks =
+ (char *)GC_MALLOC_ATOMIC(width - len + 1);
if (NULL == blanks) OUT_OF_MEMORY;
memset(blanks, ' ', width-len);
@@ -306,7 +307,7 @@ int CORD_vsprintf(CORD * out, CORD format, va_list args)
if (prec != NONE && prec > max_size) max_size = prec;
max_size += CONV_RESULT_LEN;
if (max_size >= CORD_BUFSZ) {
- buf = GC_MALLOC_ATOMIC(max_size + 1);
+ buf = (char *)GC_MALLOC_ATOMIC(max_size + 1);
if (NULL == buf) OUT_OF_MEMORY;
} else {
if (CORD_BUFSZ - (result[0].ec_bufptr-result[0].ec_buf)
diff --git a/cord/cordxtra.c b/cord/cordxtra.c
index 8a667999..827b5dbe 100644
--- a/cord/cordxtra.c
+++ b/cord/cordxtra.c
@@ -74,7 +74,7 @@ CORD CORD_cat_char(CORD x, char c)
register char * string;
if (c == '\0') return(CORD_cat(x, CORD_nul(1)));
- string = GC_MALLOC_ATOMIC(2);
+ string = (char *)GC_MALLOC_ATOMIC(2);
if (string == 0) OUT_OF_MEMORY;
string[0] = c;
string[1] = '\0';
@@ -244,7 +244,7 @@ int CORD_ncmp(CORD x, size_t x_start, CORD y, size_t y_start, size_t len)
char * CORD_to_char_star(CORD x)
{
register size_t len = CORD_len(x);
- char * result = GC_MALLOC_ATOMIC(len + 1);
+ char * result = (char *)GC_MALLOC_ATOMIC(len + 1);
if (result == 0) OUT_OF_MEMORY;
if (len > 0 && CORD_fill_buf(x, 0, len, result) != 1)
@@ -259,7 +259,7 @@ CORD CORD_from_char_star(const char *s)
size_t len = strlen(s);
if (0 == len) return(CORD_EMPTY);
- result = GC_MALLOC_ATOMIC(len + 1);
+ result = (char *)GC_MALLOC_ATOMIC(len + 1);
if (result == 0) OUT_OF_MEMORY;
memcpy(result, s, len+1);
return(result);
@@ -434,7 +434,7 @@ void CORD_ec_flush_buf(CORD_ec x)
char * s;
if (len == 0) return;
- s = GC_MALLOC_ATOMIC(len+1);
+ s = (char *)GC_MALLOC_ATOMIC(len + 1);
if (NULL == s) OUT_OF_MEMORY;
memcpy(s, x[0].ec_buf, len);
s[len] = '\0';