summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrlar <rlar>2016-02-29 20:15:29 +0100
committerWill Estes <westes575@gmail.com>2016-03-01 06:05:21 -0500
commit22d123c1fe6f6298616ae80b7be7f3a52cedf068 (patch)
tree5236fed497524cb0df1ab05f5a18a5a5864df8fa /src
parentd2c0374297b7dd687a89227f3e77ff3f244da94b (diff)
add (size_t) casts to malloc invocations to prevent warnings
Diffstat (limited to 'src')
-rw-r--r--src/filter.c6
-rw-r--r--src/misc.c6
-rw-r--r--src/scanopt.c4
-rw-r--r--src/tables.c2
4 files changed, 9 insertions, 9 deletions
diff --git a/src/filter.c b/src/filter.c
index c58406d..9500f96 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -66,7 +66,7 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
/* allocate argv, and populate it with the argument list. */
max_args = 8;
- f->argv = malloc(sizeof(char *) * (max_args + 1));
+ f->argv = malloc(sizeof(char *) * (size_t) (max_args + 1));
if (!f->argv)
flexerror(_("malloc failed (f->argv) in filter_create_ext"));
f->argv[f->argc++] = cmd;
@@ -75,7 +75,7 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd,
while ((s = va_arg (ap, const char *)) != NULL) {
if (f->argc >= max_args) {
max_args += 8;
- f->argv = realloc(f->argv, sizeof(char*) * (max_args + 1));
+ f->argv = realloc(f->argv, sizeof(char*) * (size_t) (max_args + 1));
}
f->argv[f->argc++] = s;
}
@@ -283,7 +283,7 @@ int filter_tee_header (struct filter *chain)
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
outfilename ? outfilename : "<stdout>");
- buf = malloc(readsz);
+ buf = malloc((size_t) readsz);
if (!buf)
flexerror(_("malloc failed in filter_tee_header"));
while (fgets (buf, readsz, stdin)) {
diff --git a/src/misc.c b/src/misc.c
index 0d93e4b..a2f67fc 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -60,7 +60,7 @@ static void sko_push(bool dc)
{
if(!sko_stack){
sko_sz = 1;
- sko_stack = malloc(sizeof(struct sko_state) * sko_sz);
+ sko_stack = malloc(sizeof(struct sko_state) * (size_t) sko_sz);
if (!sko_stack)
flexfatal(_("allocation of sko_stack failed"));
sko_len = 0;
@@ -68,7 +68,7 @@ static void sko_push(bool dc)
if(sko_len >= sko_sz){
sko_sz *= 2;
sko_stack = realloc(sko_stack,
- sizeof(struct sko_state) * sko_sz);
+ sizeof(struct sko_state) * (size_t) sko_sz);
}
/* initialize to zero and push */
@@ -883,7 +883,7 @@ void *yy_flex_xmalloc (int size)
{
void *result;
- result = malloc(size);
+ result = malloc((size_t) size);
if (!result)
flexfatal (_
("memory allocation failed in yy_flex_xmalloc()"));
diff --git a/src/scanopt.c b/src/scanopt.c
index d829d0f..a118541 100644
--- a/src/scanopt.c
+++ b/src/scanopt.c
@@ -157,7 +157,7 @@ scanopt_t *scanopt_init (const optspec_t *options, int argc, char **argv, int fl
s->optc++;
/* Build auxiliary data */
- s->aux = malloc(s->optc * sizeof (struct _aux));
+ s->aux = malloc((size_t) s->optc * sizeof (struct _aux));
for (i = 0; i < s->optc; i++) {
const unsigned char *p, *pname;
@@ -261,7 +261,7 @@ int scanopt_usage (scanopt_t *scanner, FILE *fp, const char *usage)
fprintf (fp, "\n");
/* Sort by r_val and string. Yes, this is O(n*n), but n is small. */
- store = malloc(s->optc * sizeof (usg_elem));
+ store = malloc((size_t) s->optc * sizeof (usg_elem));
for (i = 0; i < s->optc; i++) {
/* grab the next preallocate node. */
diff --git a/src/tables.c b/src/tables.c
index ff89b4d..3d043c6 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -481,7 +481,7 @@ void yytbl_data_compress (struct yytbl_data *tbl)
}
total_len = yytbl_calc_total_len (tbl);
- newtbl.td_data = calloc (total_len, newsz);
+ newtbl.td_data = calloc ((size_t) total_len, newsz);
newtbl.td_flags =
TFLAGS_CLRDATA (newtbl.td_flags) | BYTES2TFLAG (newsz);