summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-09-28 11:32:55 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-09-28 11:32:55 +0300
commit59d2d8ccdc4659f906287a029bab206f63a17f1f (patch)
tree48035c46d4f060bba2401b066e09b4db937c839b /cord
parentc5e49b58dd62e27c1632ae963d0e56e4885e8162 (diff)
downloadbdwgc-59d2d8ccdc4659f906287a029bab206f63a17f1f.tar.gz
Eliminate 'write to memory that was const-qualified' code analyzer warning
* cord/cordbscs.c (CORD_from_fn): Rename to CORD_from_fn_inner; make it static; change return type from CORD to CordRep*; define public CORD_from_fn which simply calls CORD_from_fn_inner (with the type cast to CORD). * cord/cordbscs.c (CORD_substr_closure): Call CORD_from_fn_inner instead of CORD_from_fn (thus remove the cast from const type to a non-const one).
Diffstat (limited to 'cord')
-rw-r--r--cord/cordbscs.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c
index 3eb63f4c..b47cad34 100644
--- a/cord/cordbscs.c
+++ b/cord/cordbscs.c
@@ -278,8 +278,7 @@ CORD CORD_cat(CORD x, CORD y)
}
-
-CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len)
+static CordRep *CORD_from_fn_inner(CORD_fn fn, void * client_data, size_t len)
{
if (len == 0) return(0);
if (len <= SHORT_LIMIT) {
@@ -298,7 +297,7 @@ CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len)
if (result == 0) OUT_OF_MEMORY;
memcpy(result, buf, len);
result[len] = '\0';
- return((CORD) result);
+ return (CordRep *)result;
}
gen_case:
{
@@ -311,10 +310,15 @@ CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len)
result->len = len;
result->fn = fn;
result->client_data = client_data;
- return((CORD) result);
+ return (CordRep *)result;
}
}
+CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len)
+{
+ return (/* const */ CORD) CORD_from_fn_inner(fn, client_data, len);
+}
+
size_t CORD_len(CORD x)
{
if (x == 0) {
@@ -356,7 +360,7 @@ CORD CORD_substr_closure(CORD x, size_t i, size_t n, CORD_fn f)
if (sa == 0) OUT_OF_MEMORY;
sa->sa_cord = (CordRep *)x;
sa->sa_index = i;
- result = (CordRep *)CORD_from_fn(f, (void *)sa, n);
+ result = CORD_from_fn_inner(f, (void *)sa, n);
if ((CORD)result != CORD_EMPTY && 0 == result -> function.null)
result -> function.header = SUBSTR_HDR;
return (CORD)result;