summaryrefslogtreecommitdiff
path: root/src/buf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/buf.c')
-rw-r--r--src/buf.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/buf.c b/src/buf.c
index c03b85f..185083c 100644
--- a/src/buf.c
+++ b/src/buf.c
@@ -100,7 +100,7 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno)
tsz = strlen("#line \"\"\n") + /* constant parts */
2 * strlen (filename) + /* filename with possibly all backslashes escaped */
- (int) (1 + log10 (abs (lineno))) + /* line number */
+ (size_t) (1 + ceil (log10 (abs (lineno)))) + /* line number */
1; /* NUL */
t = malloc(tsz);
if (!t)
@@ -166,7 +166,7 @@ struct Buf *buf_strdefine (struct Buf *buf, const char *str, const char *def)
*/
struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val)
{
- const char * fmt = "m4_define( [[%s]], [[%s]])m4_dnl\n";
+ const char * fmt = "m4_define( [[%s]], [[[[%s]]]])m4_dnl\n";
char * str;
size_t strsz;
@@ -241,26 +241,26 @@ struct Buf *buf_append (struct Buf *buf, const void *ptr, int n_elem)
n_alloc = n_elem + buf->nelts;
/* ...plus some extra */
- if (((n_alloc * buf->elt_size) % 512) != 0
+ if ((((size_t) n_alloc * buf->elt_size) % 512) != 0
&& buf->elt_size < 512)
- n_alloc +=
- (512 -
- ((n_alloc * buf->elt_size) % 512)) /
- buf->elt_size;
+ n_alloc += (int)
+ ((512 -
+ (((size_t) n_alloc * buf->elt_size) % 512)) /
+ buf->elt_size);
if (!buf->elts)
buf->elts =
- allocate_array (n_alloc, buf->elt_size);
+ allocate_array ((int) n_alloc, buf->elt_size);
else
buf->elts =
- reallocate_array (buf->elts, n_alloc,
+ reallocate_array (buf->elts, (int) n_alloc,
buf->elt_size);
buf->nmax = n_alloc;
}
- memcpy ((char *) buf->elts + buf->nelts * buf->elt_size, ptr,
- n_elem * buf->elt_size);
+ memcpy ((char *) buf->elts + (size_t) buf->nelts * buf->elt_size, ptr,
+ (size_t) n_elem * buf->elt_size);
buf->nelts += n_elem;
return buf;