diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-05 09:42:33 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-01-05 09:47:01 -0800 |
commit | 639071ff3446b0df53078be1ff5820c812313aa7 (patch) | |
tree | e0d4cf1692c44d3bfc17f06d7194fd9c7dc9459a | |
parent | 1b5e7ee6483415d7093f3d5395c4832fa69f0a28 (diff) |
Remove unnecessary casts from malloc/realloc calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | include.c | 10 | ||||
-rw-r--r-- | main.c | 10 | ||||
-rw-r--r-- | parse.c | 11 |
3 files changed, 13 insertions, 18 deletions
@@ -178,10 +178,8 @@ included_by(struct inclist *ip, struct inclist *newfile) * If it is already on the list, don't stick it on again. */ if (ip->i_list == NULL) { - ip->i_list = (struct inclist **) - malloc(sizeof(struct inclist *) * ++ip->i_listlen); - ip->i_merged = (boolean *) - malloc(sizeof(boolean) * ip->i_listlen); + ip->i_list = malloc(sizeof(struct inclist *) * ++ip->i_listlen); + ip->i_merged = malloc(sizeof(boolean) * ip->i_listlen); } else { for (i=0; i<ip->i_listlen; i++) if (ip->i_list[ i ] == newfile) { @@ -205,9 +203,9 @@ included_by(struct inclist *ip, struct inclist *newfile) } return; } - ip->i_list = (struct inclist **) realloc(ip->i_list, + ip->i_list = realloc(ip->i_list, sizeof(struct inclist *) * ++ip->i_listlen); - ip->i_merged = (boolean *) + ip->i_merged = realloc(ip->i_merged, sizeof(boolean) * ip->i_listlen); } ip->i_list[ ip->i_listlen-1 ] = newfile; @@ -187,7 +187,7 @@ main(int argc, char *argv[]) if ((afd = open(argv[1]+1, O_RDONLY)) < 0) fatalerr("cannot open \"%s\"\n", argv[1]+1); fstat(afd, &ast); - args = (char *)malloc(ast.st_size + 1); + args = malloc(ast.st_size + 1); if ((ast.st_size = read(afd, args, ast.st_size)) < 0) fatalerr("failed to read %s\n", argv[1]+1); args[ast.st_size] = '\0'; @@ -215,7 +215,7 @@ main(int argc, char *argv[]) } if (p[-1]) nargc++; - nargv = (char **)malloc(nargc * sizeof(char *)); + nargv = malloc(nargc * sizeof(char *)); nargv[0] = argv[0]; argc = 1; for (p = args; argc < nargc; p += strlen(p) + 1) @@ -503,16 +503,16 @@ getfile(const char *file) struct filepointer *content; struct stat st; - content = (struct filepointer *)malloc(sizeof(struct filepointer)); + content = malloc(sizeof(struct filepointer)); content->f_name = file; if ((fd = open(file, O_RDONLY)) < 0) { warning("cannot open \"%s\"\n", file); - content->f_p = content->f_base = content->f_end = (char *)malloc(1); + content->f_p = content->f_base = content->f_end = malloc(1); *content->f_p = '\0'; return(content); } fstat(fd, &st); - content->f_base = (char *)malloc(st.st_size+1); + content->f_base = malloc(st.st_size+1); if (content->f_base == NULL) fatalerr("cannot allocate mem\n"); if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0) @@ -322,13 +322,11 @@ define2(const char *name, const char *val, struct inclist *file) /* Make space if it's needed */ if (file->i_defs == NULL) { - file->i_defs = (struct symtab **) - malloc(sizeof (struct symtab*) * SYMTABINC); + file->i_defs = malloc(sizeof (struct symtab*) * SYMTABINC); file->i_ndefs = 0; } else if (!(file->i_ndefs % SYMTABINC)) - file->i_defs = (struct symtab **) - realloc(file->i_defs, + file->i_defs = realloc(file->i_defs, sizeof(struct symtab*)*(file->i_ndefs+SYMTABINC)); if (file->i_defs == NULL) @@ -387,7 +385,7 @@ define2(const char *name, const char *val, struct inclist *file) *sp = sp[-1]; sp--; } - stab = (struct symtab *) malloc(sizeof (struct symtab)); + stab = malloc(sizeof (struct symtab)); if (stab == NULL) fatalerr("malloc()/realloc() failure in insert_defn()\n"); @@ -492,8 +490,7 @@ merge2defines(struct inclist *file1, struct inclist *file2) { /* make sure deflen % SYMTABINC == 0 is still true */ deflen += (SYMTABINC - deflen % SYMTABINC) % SYMTABINC; - i_defs=(struct symtab**) - malloc(deflen*sizeof(struct symtab*)); + i_defs = malloc(deflen*sizeof(struct symtab*)); if (i_defs==NULL) return 0; } |