From: m@mmmmarascio.xyz Date: Thu, 17 Mar 2016 15:16:26 +0000 (-0700) Subject: remove unnecessary casts X-Git-Tag: mmh-0.3~53 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=b78007de9802005825390bee71dfce2306b42519;p=mmh remove unnecessary casts These casts after malloc just make the code harder to read --- diff --git a/sbr/addrsbr.c b/sbr/addrsbr.c index 96fa72f..dc3924b 100644 --- a/sbr/addrsbr.c +++ b/sbr/addrsbr.c @@ -104,7 +104,7 @@ getm(char *str, char *dfhost, int dftype, int wanthost, char *eresult) dftype = LOCALHOST; } - mp = (struct mailname *) mh_xcalloc((size_t) 1, sizeof(*mp)); + mp = mh_xcalloc(1, sizeof(*mp)); if (mp == NULL) { if (eresult) strcpy(eresult, "insufficient memory to represent address"); diff --git a/sbr/brkstring.c b/sbr/brkstring.c index acbba6a..a9446fe 100644 --- a/sbr/brkstring.c +++ b/sbr/brkstring.c @@ -30,7 +30,7 @@ brkstring(char *str, char *brksep, char *brkterm) /* allocate initial space for pointers on first call */ if (!broken) { len = NUMBROKEN; - broken = (char **)mh_xcalloc((size_t)len, sizeof(*broken)); + broken = mh_xcalloc(len, sizeof(*broken)); } /* @@ -42,8 +42,7 @@ brkstring(char *str, char *brksep, char *brkterm) /* enlarge pointer array, if necessary */ if (i >= len) { len += NUMBROKEN; - broken = mh_xrealloc(broken, - (size_t)(len * sizeof(*broken))); + broken = mh_xrealloc(broken, len * sizeof(*broken)); } /* handle separators */ diff --git a/sbr/context_replace.c b/sbr/context_replace.c index 2c3bc18..0a31bba 100644 --- a/sbr/context_replace.c +++ b/sbr/context_replace.c @@ -19,7 +19,7 @@ context_replace(char *key, char *value) ** If list is emtpy, allocate head of profile/context list. */ if (!m_defs) { - m_defs = (struct node *) mh_xcalloc(1, sizeof(*np)); + m_defs = mh_xcalloc(1, sizeof(*np)); np = m_defs; np->n_name = getcpy(key); @@ -53,7 +53,7 @@ context_replace(char *key, char *value) /* ** Else add this new entry at the end */ - np->n_next = (struct node *) mh_xcalloc(1, sizeof(*np)); + np->n_next = mh_xcalloc(1, sizeof(*np)); np = np->n_next; np->n_name = getcpy(key); diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 096f7dd..85ed7d7 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -209,7 +209,7 @@ static struct ftable functable[] = { /* Add new component to the hash table */ #define NEWCOMP(cm,name) do { \ - cm = ((struct comp *) mh_xcalloc(1, sizeof (struct comp)));\ + cm = (mh_xcalloc(1, sizeof (struct comp)));\ cm->c_name = name;\ ncomp++;\ i = CHASH(name);\ @@ -328,8 +328,7 @@ fmt_compile(char *fstring, struct format **fmt) i = strlen(fstring)/2 + 1; if (i == 1) i++; - next_fp = formatvec = (struct format *)mh_xcalloc((size_t) i, - sizeof(struct format)); + next_fp = formatvec = mh_xcalloc(i, sizeof(struct format)); if (next_fp == NULL) adios(EX_OSERR, NULL, "unable to allocate format storage"); @@ -480,8 +479,7 @@ do_name(char *sp, int preprocess) if (cm->c_type & CT_ADDR) { CERROR("component used as both date and address"); } - cm->c_tws = (struct tws *) - mh_xcalloc((size_t) 1, sizeof(*cm->c_tws)); + cm->c_tws = mh_xcalloc(1, sizeof(*cm->c_tws)); fp->f_type = preprocess; PUTCOMP(sp); cm->c_type |= CT_DATE; diff --git a/sbr/fmt_new.c b/sbr/fmt_new.c index c3b1ea2..874129a 100644 --- a/sbr/fmt_new.c +++ b/sbr/fmt_new.c @@ -43,7 +43,7 @@ new_fs(char *form, char *def_form) if (fstat(fileno(fp), &st) == -1) { adios(EX_IOERR, form, "unable to stat format file"); } - formats = mh_xcalloc((size_t) st.st_size + 1, sizeof(char)); + formats = mh_xcalloc(st.st_size + 1, sizeof(char)); if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) { adios(EX_IOERR, form, "error reading format file"); } @@ -60,7 +60,7 @@ new_fs(char *form, char *def_form) if (fstat(fileno(fp), &st) == -1) { adios(EX_IOERR, def_form, "unable to stat format file"); } - formats = mh_xcalloc((size_t) st.st_size + 1, sizeof(char)); + formats = mh_xcalloc(st.st_size + 1, sizeof(char)); if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) { adios(EX_IOERR, def_form, "error reading format file"); } diff --git a/sbr/fmt_rfc2047.c b/sbr/fmt_rfc2047.c index e9db55e..0932e34 100644 --- a/sbr/fmt_rfc2047.c +++ b/sbr/fmt_rfc2047.c @@ -209,7 +209,7 @@ decode_rfc2047(char *str, char *dst, size_t dstlen) if (use_iconv) { saveq = q; savedstlen = dstlen; - q = convbuf = (char *) mh_xcalloc(endofmime - startofmime, sizeof(char)); + q = convbuf = mh_xcalloc(endofmime - startofmime, sizeof(char)); } /* ** ADDCHR2 is for adding characters when q is or might be convbuf: diff --git a/sbr/folder_read.c b/sbr/folder_read.c index 67775f1..1c68d0d 100644 --- a/sbr/folder_read.c +++ b/sbr/folder_read.c @@ -46,7 +46,7 @@ folder_read(char *name) } /* Allocate the main structure for folder information */ - mp = (struct msgs *) mh_xcalloc(1, (size_t) sizeof(*mp)); + mp = mh_xcalloc(1, sizeof(*mp)); clear_folder_flags(mp); mp->foldpath = name; @@ -66,7 +66,7 @@ folder_read(char *name) ** name of the messages in this folder. */ len = NUMMSGS; - mi = (int *) mh_xcalloc((size_t) len, sizeof(*mi)); + mi = mh_xcalloc(len, sizeof(*mi)); while ((dp = readdir(dd))) { if ((msgnum = m_atoi(dp->d_name)) && msgnum > 0) { @@ -76,7 +76,7 @@ folder_read(char *name) */ if (mp->nummsg >= len) { len += NUMMSGS; - mi = (int *) mh_xrealloc(mi, (size_t) (len * sizeof(*mi))); + mi = mh_xrealloc(mi, len * sizeof(*mi)); } /* Check if this is the first message we've seen */ diff --git a/sbr/getarguments.c b/sbr/getarguments.c index a700443..33db7f7 100644 --- a/sbr/getarguments.c +++ b/sbr/getarguments.c @@ -28,7 +28,7 @@ getarguments(char *invo_name, int argc, char **argv, int check_context) n++; } - arguments = (char **) mh_xcalloc(argc + n, sizeof(*arguments)); + arguments = mh_xcalloc(argc + n, sizeof(*arguments)); bp = arguments; /* Copy any arguments from profile/context */ diff --git a/sbr/getcpy.c b/sbr/getcpy.c index 77564a1..67375bb 100644 --- a/sbr/getcpy.c +++ b/sbr/getcpy.c @@ -25,7 +25,7 @@ getcpy(char *str) cp = mh_xcalloc(len, sizeof(char)); memcpy(cp, str, len); } else { - cp = mh_xcalloc((size_t) 1, sizeof(char)); + cp = mh_xcalloc(1, sizeof(char)); *cp = '\0'; } return cp; diff --git a/sbr/lock_file.c b/sbr/lock_file.c index 3aa0030..07302e5 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -516,7 +516,7 @@ timerON(char *curlock, int fd) struct lock *lp; size_t len; - lp = (struct lock *) mh_xcalloc(1, sizeof(*lp)); + lp = mh_xcalloc(1, sizeof(*lp)); len = strlen(curlock) + 1; lp->l_fd = fd; diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index 6931b2e..1ec09a4 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -609,7 +609,7 @@ thisisanmbox(FILE *iob) continue; } c = strlen(delimstr); - fdelim = (unsigned char *) mh_xcalloc((size_t) (c + 3), sizeof(char)); + fdelim = mh_xcalloc(c + 3, sizeof(char)); *fdelim++ = '\0'; *fdelim = '\n'; msg_delim = (char *)fdelim+1; @@ -626,7 +626,7 @@ thisisanmbox(FILE *iob) ** separator) or the last char (since the matchc would have found it ** if it was a real delim). */ - pat_map = (unsigned char **) mh_xcalloc(256, sizeof(unsigned char *)); + pat_map = mh_xcalloc(256, sizeof(unsigned char *)); for (cp = (char *) fdelim + 1; cp < (char *) delimend; cp++ ) pat_map[(unsigned char)*cp] = (unsigned char *) cp; diff --git a/sbr/mf.c b/sbr/mf.c index 3134328..7c6f004 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -42,7 +42,7 @@ getcpy(char *s) for(;;) pause(); } - p = mh_xcalloc((size_t) (strlen(s) + 2), sizeof(char)); + p = mh_xcalloc(strlen(s) + 2, sizeof(char)); strcpy(p, s); return p; } diff --git a/sbr/putenv.c b/sbr/putenv.c index 54c4068..c47f26e 100644 --- a/sbr/putenv.c +++ b/sbr/putenv.c @@ -25,7 +25,7 @@ m_putenv(char *name, char *value) int i; char **ep, **nep, *cp; - cp = mh_xcalloc((size_t) (strlen(name) + strlen(value) + 2), sizeof(char)); + cp = mh_xcalloc(strlen(name) + strlen(value) + 2, sizeof(char)); sprintf(cp, "%s=%s", name, value); @@ -35,7 +35,7 @@ m_putenv(char *name, char *value) return 0; } - nep = (char **) mh_xcalloc((size_t) (i + 2), sizeof(*nep)); + nep = mh_xcalloc(i + 2, sizeof(*nep)); for (ep = environ, i = 0; *ep; nep[i++] = *ep++) continue; diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 747aede..c99b7cd 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -52,7 +52,7 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx) ib)) { case FLD: case FLDPLUS: - np = (struct node *) mh_xcalloc(1, sizeof(*np)); + np = mh_xcalloc(1, sizeof(*np)); *npp = np; *(npp = &np->n_next) = NULL; np->n_name = getcpy(name); diff --git a/sbr/seq_list.c b/sbr/seq_list.c index 241c720..3606f6f 100644 --- a/sbr/seq_list.c +++ b/sbr/seq_list.c @@ -27,7 +27,7 @@ seq_list(struct msgs *mp, char *seqname) /* On first invocation, allocate initial buffer space */ if (!buffer) { len = MAXBUFFER; - buffer = mh_xcalloc((size_t) len, sizeof(char)); + buffer = mh_xcalloc(len, sizeof(char)); } /* @@ -72,7 +72,7 @@ seq_list(struct msgs *mp, char *seqname) char *newbuf; len += MAXBUFFER; - newbuf = mh_xrealloc(buffer, (size_t) len); + newbuf = mh_xrealloc(buffer, len); bp = newbuf + (bp - buffer); buffer = newbuf; } diff --git a/sbr/utils.c b/sbr/utils.c index f964e7e..2744581 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -31,7 +31,7 @@ mh_xrealloc(void *ptr, size_t size) /* Some non-POSIX realloc()s don't cope with realloc(NULL,sz) */ if (!ptr) { - return mh_xcalloc((size_t) 1, size); + return mh_xcalloc(1, size); } if (size == 0) { adios(EX_SOFTWARE, NULL, "Tried to realloc 0 bytes"); diff --git a/sbr/vfgets.c b/sbr/vfgets.c index 1718ff1..1ddd99b 100644 --- a/sbr/vfgets.c +++ b/sbr/vfgets.c @@ -22,7 +22,7 @@ vfgets(FILE *in, char **bp) static char *pp = NULL; if (pp == NULL) - pp = mh_xcalloc((size_t) (len = BUFSIZ), sizeof(char)); + pp = mh_xcalloc(len = BUFSIZ, sizeof(char)); for (ep = (cp = pp) + len - 1;;) { if (fgets(cp, ep - cp + 1, in) == NULL) { @@ -64,7 +64,7 @@ wrong_guess: if (cp >= ep) { int curlen = cp - pp; - dp = mh_xrealloc(pp, (size_t) (len += BUFSIZ)); + dp = mh_xrealloc(pp, len += BUFSIZ); cp = dp + curlen; ep = (pp = dp) + len - 1; } diff --git a/uip/aliasbr.c b/uip/aliasbr.c index 744d3bf..1fbcc7a 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -431,7 +431,7 @@ add_aka(struct aka *ak, char *pp) if (strcmp(pp, ad->ad_text)==0) return; - ad = (struct adr *) mh_xcalloc(1, sizeof(*ad)); + ad = mh_xcalloc(1, sizeof(*ad)); ad->ad_text = getcpy(pp); ad->ad_local = strchr(pp, '@') == NULL; ad->ad_next = NULL; @@ -468,7 +468,7 @@ akalloc(char *id) { struct aka *p; - p = (struct aka *) mh_xcalloc(1, sizeof(*p)); + p = mh_xcalloc(1, sizeof(*p)); p->ak_name = getcpy(id); p->ak_visible = 0; @@ -489,7 +489,7 @@ hmalloc(struct passwd *pw) { struct home *p; - p = (struct home *) mh_xcalloc(1, sizeof(*p)); + p = mh_xcalloc(1, sizeof(*p)); p->h_name = getcpy(pw->pw_name); p->h_uid = pw->pw_uid; diff --git a/uip/anno.c b/uip/anno.c index 96b896c..66e62c5 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -305,7 +305,7 @@ annolist(char *file, unsigned char *comp, int number) } /* We'll grow this buffer as needed. */ - field = (char *)mh_xcalloc(field_size = 256, sizeof(char)); + field = mh_xcalloc(field_size = 256, sizeof(char)); make_comp(&comp); length = strlen(comp); /* Convenience copy. */ @@ -325,8 +325,7 @@ annolist(char *file, unsigned char *comp, int number) break; } if (++n >= field_size - 1) { - field = (char *)mh_xrealloc(field, - field_size += 256); + field = mh_xrealloc(field, field_size += 256); cp = field + n - 1; } } @@ -459,7 +458,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number) if ((fp = fdopen(fd, "r")) == NULL) { adios(EX_IOERR, NULL, "unable to fdopen file."); } - field = (char *)mh_xcalloc(field_size, sizeof(char)); + field = mh_xcalloc(field_size, sizeof(char)); /* ** Copy lines from the input file to the temporary file @@ -487,8 +486,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number) } if (++n >= field_size - 1) { - field = (char *) mh_xrealloc(field, - field_size *= 2); + field = mh_xrealloc(field, field_size *= 2); cp = field + n - 1; } } diff --git a/uip/ap.c b/uip/ap.c index e2d43da..5b9677f 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -138,7 +138,7 @@ process(char *arg, int norm) (q = &pq)->pq_next = NULL; while ((cp = getname(arg))) { - p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p)); + p = mh_xcalloc(1, sizeof(*p)); if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) { p->pq_text = getcpy(cp); p->pq_error = getcpy(error); diff --git a/uip/burst.c b/uip/burst.c index 04e5450..119a936 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -117,8 +117,7 @@ main(int argc, char **argv) exit(EX_SOFTWARE); seq_setprev(mp); /* set the previous-sequence */ - smsgs = (struct smsg *) - mh_xcalloc((size_t) (MAXFOLDER + 2), sizeof(*smsgs)); + smsgs = mh_xcalloc(MAXFOLDER + 2, sizeof(*smsgs)); hi = mp->hghmsg + 1; diff --git a/uip/flist.c b/uip/flist.c index d2433a2..f7e5ba3 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -143,7 +143,7 @@ main(int argc, char **argv) /* allocate the initial space to record the folder names */ numfolders = 0; maxfolders = MAXFOLDERS; - foldersToDo = (char **) mh_xcalloc((size_t) maxfolders, sizeof(*foldersToDo)); + foldersToDo = mh_xcalloc(maxfolders, sizeof(*foldersToDo)); /* no sequences yet */ numsequences = 0; @@ -220,7 +220,7 @@ main(int argc, char **argv) */ if (numfolders >= maxfolders) { maxfolders += MAXFOLDERS; - foldersToDo = (char **) mh_xrealloc(foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo))); + foldersToDo = mh_xrealloc(foldersToDo, maxfolders * sizeof(*foldersToDo)); } if (*cp == '+' || *cp == '@') { foldersToDo[numfolders++] = getcpy(expandfol(cp)); @@ -294,7 +294,7 @@ GetFolderOrder(void) AllocFolders(&orders, &nOrdersAlloced, nOrders + 1); o = &orders[nOrders++]; o->priority = priority++; - o->name = (char *) mh_xcalloc(p - s + 1, sizeof(char)); + o->name = mh_xcalloc(p - s + 1, sizeof(char)); strncpy(o->name, s, p - s); o->name[p - s] = 0; } else @@ -623,11 +623,10 @@ AllocFolders(struct Folder **f, int *nfa, int n) return; if (*f == NULL) { *nfa = 10; - *f = (struct Folder *) mh_xcalloc(*nfa, sizeof(struct Folder)); + *f = mh_xcalloc(*nfa, sizeof(struct Folder)); } else { *nfa *= 2; - *f = (struct Folder *) mh_xrealloc( - *f, *nfa * (sizeof(struct Folder))); + *f = mh_xrealloc(*f, *nfa * sizeof(struct Folder)); } } diff --git a/uip/forw.c b/uip/forw.c index 77339b3..243c918 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -333,7 +333,7 @@ build_form(char *form, char *digest, int volume, int issue) if ((in = dup(fileno(tmp))) == NOTOK) adios(EX_OSERR, "dup", "unable to"); - line = mh_xcalloc((unsigned) fmtsize, sizeof(char)); + line = mh_xcalloc(fmtsize, sizeof(char)); fmt_scan(fmt, line, fmtsize, dat); fputs(line, tmp); free(line); diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 76826c3..ca7c5bf 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -330,7 +330,7 @@ build_mime(char *infile) /* ** Allocate space for primary (outside) content */ - ct = (CT) mh_xcalloc(1, sizeof(*ct)); + ct = mh_xcalloc(1, sizeof(*ct)); /* ** Allocate structure for handling decoded content @@ -434,7 +434,7 @@ build_mime(char *infile) ct->c_subtype = MULTI_MIXED; ct->c_file = getcpy(infile); - m = (struct multipart *) mh_xcalloc(1, sizeof(*m)); + m = mh_xcalloc(1, sizeof(*m)); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -453,7 +453,7 @@ build_mime(char *infile) if (!p) continue; - part = (struct part *) mh_xcalloc(1, sizeof(*part)); + part = mh_xcalloc(1, sizeof(*part)); *pp = part; pp = &part->mp_next; part->mp_part = p; @@ -533,7 +533,7 @@ init_decoded_content(CT ct) { CE ce; - ce = (CE) mh_xcalloc(1, sizeof(*ce)); + ce = mh_xcalloc(1, sizeof(*ce)); ct->c_cefile = ce; ct->c_ceopenfnx = open7Bit; /* since unencoded */ @@ -593,7 +593,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp) } /* allocate basic Content structure */ - ct = (CT) mh_xcalloc(1, sizeof(*ct)); + ct = mh_xcalloc(1, sizeof(*ct)); *ctp = ct; /* allocate basic structure for handling decoded content */ @@ -901,7 +901,7 @@ use_forw: ct->c_type = CT_MULTIPART; ct->c_subtype = MULTI_DIGEST; - m = (struct multipart *) mh_xcalloc(1, sizeof(*m)); + m = mh_xcalloc(1, sizeof(*m)); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -911,7 +911,7 @@ use_forw: CT p; CE pe; - p = (CT) mh_xcalloc(1, sizeof(*p)); + p = mh_xcalloc(1, sizeof(*p)); init_decoded_content(p); pe = p->c_cefile; if (get_ctinfo("message/rfc822", p, 0) @@ -925,7 +925,7 @@ use_forw: msgnum); pe->ce_file = getcpy(buffer); - part = (struct part *) mh_xcalloc(1, sizeof(*part)); + part = mh_xcalloc(1, sizeof(*part)); *pp = part; pp = &part->mp_next; part->mp_part = p; @@ -984,7 +984,7 @@ use_forw: ct->c_type = CT_MULTIPART; ct->c_subtype = vrsn; - m = (struct multipart *) mh_xcalloc(1, sizeof(*m)); + m = mh_xcalloc(1, sizeof(*m)); ct->c_ctparams = (void *) m; pp = &m->mp_parts; @@ -1000,7 +1000,7 @@ use_forw: if (!p) continue; - part = (struct part *) mh_xcalloc(1, sizeof(*part)); + part = mh_xcalloc(1, sizeof(*part)); *pp = part; pp = &part->mp_next; part->mp_part = p; diff --git a/uip/mhl.c b/uip/mhl.c index 15489ff..6f87d62 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -780,7 +780,7 @@ mcomp_format(struct mcomp *c1, struct mcomp *c2) (q = &pq)->pq_next = NULL; while ((cp = getname(ap))) { - p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p)); + p = mh_xcalloc(1, sizeof(*p)); if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) { p->pq_text = getcpy(cp); @@ -827,7 +827,7 @@ add_queue(struct mcomp **head, struct mcomp **tail, char *name, { struct mcomp *c1; - c1 = (struct mcomp *) mh_xcalloc((size_t) 1, sizeof(*c1)); + c1 = mh_xcalloc(1, sizeof(*c1)); c1->c_flags = flags & ~INIT; if ((c1->c_name = name ? getcpy(name) : NULL)) diff --git a/uip/mhlist.c b/uip/mhlist.c index 6d7b8e7..4609012 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -197,7 +197,7 @@ main(int argc, char **argv) ** check if message is coming from file */ if (file) { - cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts)); + cts = mh_xcalloc(2, sizeof(*cts)); ctp = cts; if ((ct = parse_mime(file))) @@ -231,8 +231,7 @@ main(int argc, char **argv) } seq_setprev(mp); /* set the previous-sequence */ - cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1), - sizeof(*cts)); + cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { diff --git a/uip/mhparse.c b/uip/mhparse.c index 3522a97..d3f543f 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -238,7 +238,7 @@ get_content(FILE *in, char *file, int toplevel) HF hp; /* allocate the content structure */ - ct = (CT) mh_xcalloc(1, sizeof(*ct)); + ct = mh_xcalloc(1, sizeof(*ct)); ct->c_fp = in; ct->c_file = getcpy(file); @@ -976,7 +976,7 @@ InitText(CT ct) ct->c_subtype = kv->kv_value; /* allocate text character set structure */ - t = (struct text *) mh_xcalloc(1, sizeof(*t)); + t = mh_xcalloc(1, sizeof(*t)); ct->c_ctparams = (void *) t; /* scan for charset parameter */ @@ -1057,7 +1057,7 @@ InitMultiPart(CT ct) } /* allocate primary structure for multipart info */ - m = (struct multipart *) mh_xcalloc(1, sizeof(*m)); + m = mh_xcalloc(1, sizeof(*m)); ct->c_ctparams = (void *) m; /* check if boundary parameter contains only whitespace characters */ @@ -1100,7 +1100,7 @@ InitMultiPart(CT ct) if (strcmp(buffer + 2, m->mp_start)!=0) continue; next_part: - part = (struct part *) mh_xcalloc(1, sizeof(*part)); + part = mh_xcalloc(1, sizeof(*part)); *next = part; next = &part->mp_next; @@ -1214,7 +1214,7 @@ reverse_parts(CT ct) i++; /* allocate array of pointers to the parts */ - base = (struct part **) mh_xcalloc((size_t) (i + 1), sizeof(*base)); + base = mh_xcalloc(i + 1, sizeof(*base)); bmp = base; /* point at all the parts */ @@ -1270,7 +1270,7 @@ InitMessage(CT ct) char **ap, **ep; struct partial *p; - p = (struct partial *) mh_xcalloc(1, sizeof(*p)); + p = mh_xcalloc(1, sizeof(*p)); ct->c_ctparams = (void *) p; /* @@ -1382,7 +1382,7 @@ init_encoding(CT ct, OpenCEFunc openfnx) { CE ce; - ce = (CE) mh_xcalloc(1, sizeof(*ce)); + ce = mh_xcalloc(1, sizeof(*ce)); ct->c_cefile = ce; ct->c_ceopenfnx = openfnx; diff --git a/uip/mhshow.c b/uip/mhshow.c index bb03939..691ef8c 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -249,7 +249,7 @@ main(int argc, char **argv) ** check if message is coming from file */ if (file) { - cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts)); + cts = mh_xcalloc(2, sizeof(*cts)); ctp = cts; if ((ct = parse_mime(file))) @@ -303,8 +303,7 @@ main(int argc, char **argv) seq_setprev(mp); /* set the Previous-Sequence */ seq_setunseen(mp, 0); /* unset unseen seqs for shown msgs */ - cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1), - sizeof(*cts)); + cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; /* diff --git a/uip/mhstore.c b/uip/mhstore.c index fae054f..519991f 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -261,7 +261,7 @@ main(int argc, char **argv) ** check if message is coming from file */ if (file) { - cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts)); + cts = mh_xcalloc(2, sizeof(*cts)); ctp = cts; if ((ct = parse_mime(file))) @@ -293,8 +293,7 @@ main(int argc, char **argv) exit(EX_USAGE); seq_setprev(mp); /* set the previous-sequence */ - cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1), - sizeof(*cts)); + cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { @@ -568,7 +567,7 @@ store_partial(CT ct) return NOTOK; } - base = (CT *) mh_xcalloc((size_t) (i + 1), sizeof(*base)); + base = mh_xcalloc(i + 1, sizeof(*base)); ctq = base; for (ctp = cts; *ctp; ctp++) { diff --git a/uip/mhtest.c b/uip/mhtest.c index dd45626..5b9f669 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -209,7 +209,7 @@ main(int argc, char **argv) ** check if message is coming from file */ if (file) { - cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts)); + cts = mh_xcalloc(2, sizeof(*cts)); ctp = cts; if ((ct = parse_mime(file))) @@ -241,8 +241,7 @@ main(int argc, char **argv) exit(EX_USAGE); seq_setprev(mp); /* set the previous-sequence */ - cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1), - sizeof(*cts)); + cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts)); ctp = cts; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { diff --git a/uip/pick.c b/uip/pick.c index 320db19..b12597b 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -768,7 +768,7 @@ newnexus(int (*action)()) { struct nexus *p; - p = (struct nexus *) mh_xcalloc((size_t) 1, sizeof *p); + p = mh_xcalloc(1, sizeof *p); p->n_action = action; return p; diff --git a/uip/rcvdist.c b/uip/rcvdist.c index deeccb8..59ffdf2 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -170,11 +170,8 @@ rcvdistout(FILE *inb, char *form, char *addrs) cp = new_fs(form ? form : rcvdistcomps, NULL); format_len = strlen(cp); ncomps = fmt_compile(cp, &fmt) + 1; - nxtbuf = compbuffers = - (char **) mh_xcalloc((size_t) ncomps, sizeof(char *)); - savecomp = used_buf = - (struct comp **) mh_xcalloc((size_t) (ncomps + 1), - sizeof(struct comp *)); + nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof(char *)); + savecomp = used_buf = mh_xcalloc(ncomps + 1, sizeof(struct comp *)); savecomp += ncomps + 1; *--savecomp = 0; @@ -252,7 +249,7 @@ rcvdistout(FILE *inb, char *form, char *addrs) finished: ; i = format_len + char_read + 256; - scanl = mh_xcalloc((size_t) i + 2, sizeof(char)); + scanl = mh_xcalloc(i + 2, sizeof(char)); dat[0] = dat[1] = dat[2] = dat[4] = 0; dat[3] = OUTPUTLINELEN; fmt_scan(fmt, scanl, i, dat); diff --git a/uip/repl.c b/uip/repl.c index fa1a7b4..cd0f6be 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -412,10 +412,8 @@ replout(FILE *inb, char *drft, struct msgs *mp, /* compile format string */ ncomps = fmt_compile(cp, &fmt) + 1; - nxtbuf = compbuffers = (char **) - mh_xcalloc((size_t) ncomps, sizeof(char *)); - savecomp = used_buf = (struct comp **) - mh_xcalloc((size_t) (ncomps+1), sizeof(struct comp *)); + nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof(char *)); + savecomp = used_buf = mh_xcalloc(ncomps+1, sizeof(struct comp *)); savecomp += ncomps + 1; *--savecomp = NULL; /* point at zero'd end minus 1 */ @@ -543,7 +541,7 @@ finished: } } i = format_len + char_read + 256; - scanl = mh_xcalloc((size_t) i + 2, sizeof(char)); + scanl = mh_xcalloc(i + 2, sizeof(char)); dat[0] = 0; dat[1] = 0; dat[2] = 0; diff --git a/uip/rmm.c b/uip/rmm.c index 896497f..3237deb 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -131,7 +131,7 @@ main(int argc, char **argv) adios(EX_SOFTWARE, NULL, "more than %d messages for refile exec", MAXARGS - 6); } - vec = (char **)mh_xcalloc((size_t)(msgs.size + 6), sizeof(*vec)); + vec = mh_xcalloc(msgs.size + 6, sizeof(*vec)); vec[vecp++] = "refile"; vec[vecp++] = "-src"; vec[vecp++] = concat("+", folder, NULL); diff --git a/uip/scansbr.c b/uip/scansbr.c index ed163f3..877bdef 100644 --- a/uip/scansbr.c +++ b/uip/scansbr.c @@ -88,8 +88,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, width = MAXSCANL; } dat[3] = slwidth = width; - scanl = (char *) mh_xcalloc((size_t)(slwidth + 2), - SCAN_CHARWIDTH); /* probably for \n and \0 */ + scanl = mh_xcalloc(slwidth + 2, SCAN_CHARWIDTH); /* probably for \n and \0 */ /* Compile format string */ ncomps = fmt_compile(fmtstr, &fmt) + 1; FINDCOMP(datecomp, "date"); @@ -98,10 +97,8 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg, datecomp = NULL; } - nxtbuf = compbuffers = (char **) mh_xcalloc((size_t) ncomps, - sizeof(char *)); - used_buf = (struct comp **) mh_xcalloc((size_t) (ncomps+1), - sizeof(struct comp *)); + nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof(char *)); + used_buf = mh_xcalloc(ncomps+1, sizeof(struct comp *)); /* NULL-terminate array */ used_buf += ncomps; *used_buf = NULL; @@ -259,7 +256,7 @@ finished: if (datecomp && !datecomp->c_text) { if (!datecomp->c_text) { if (!datecomp->c_tws) - datecomp->c_tws = (struct tws *) mh_xcalloc((size_t) 1, sizeof(*datecomp->c_tws)); + datecomp->c_tws = mh_xcalloc(1, sizeof(*datecomp->c_tws)); if (!datecomp->c_tws) adios(EX_OSERR, NULL, "unable to allocate tws buffer"); *datecomp->c_tws = *dlocaltime((time_t *) &st.st_mtime); diff --git a/uip/send.c b/uip/send.c index d47ba8e..d7cf204 100644 --- a/uip/send.c +++ b/uip/send.c @@ -348,7 +348,7 @@ attach(char *draft_file_name) } /* We'll grow the buffer as needed. */ - field = (char *)mh_xcalloc(field_size = 256, sizeof(char)); + field = mh_xcalloc(field_size = 256, sizeof(char)); /* ** Scan the draft file for an attachment header field name. @@ -484,7 +484,7 @@ signandenc(char *draft_file_name) } /* We'll grow the buffer as needed. */ - field = (char *)mh_xcalloc(field_size = 256, sizeof(char)); + field = mh_xcalloc(field_size = 256, sizeof(char)); /* Scan the draft file for an attachment header field name. */ while (get_line() != EOF && *field != '\0' && *field != '-') { @@ -553,7 +553,7 @@ get_line(void) break; } if (++n >= field_size - 1) { - field = (char *)mh_xrealloc(field, field_size += 256); + field = mh_xrealloc(field, field_size += 256); p = field + n - 1; } } diff --git a/uip/sortm.c b/uip/sortm.c index 06ec0ca..470fa8b 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -197,7 +197,7 @@ main(int argc, char **argv) /* ** sort a list of pointers to our "messages to be sorted". */ - dlist = (struct smsg **) mh_xcalloc((size_t) (nmsgs+1), sizeof(*dlist)); + dlist = mh_xcalloc(nmsgs+1, sizeof(*dlist)); for (i = 0; i < nmsgs; i++) dlist[i] = &smsgs[i]; dlist[nmsgs] = 0; @@ -224,7 +224,7 @@ main(int argc, char **argv) struct smsg **slist, **flist; struct smsg ***il, **fp, **dp; - slist = (struct smsg **) mh_xcalloc(nmsgs+1, sizeof(*slist)); + slist = mh_xcalloc(nmsgs+1, sizeof(*slist)); memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist)); qsort((char *)slist, nmsgs, sizeof(*slist), (qsort_comp) subsort); @@ -234,7 +234,7 @@ main(int argc, char **argv) ** the collection of messages with the same subj ** given a message number. */ - il = (struct smsg ***) mh_xcalloc(mp->hghsel+1, sizeof(*il)); + il = mh_xcalloc(mp->hghsel+1, sizeof(*il)); if (! il) adios(EX_OSERR, NULL, "couldn't allocate msg list"); for (i = 0; i < nmsgs; i++) @@ -243,7 +243,7 @@ main(int argc, char **argv) ** make up the final list, chronological but with ** all the same subjects grouped together. */ - flist = (struct smsg **) mh_xcalloc(nmsgs+1, sizeof(*flist)); + flist = mh_xcalloc(nmsgs+1, sizeof(*flist)); fp = flist; for (dp = dlist; *dp;) { struct smsg **s = il[(*dp++)->s_msg]; @@ -293,8 +293,7 @@ read_hdrs(struct msgs *mp, char *datesw) twscopy(&tb, dlocaltimenow()); - smsgs = (struct smsg *) mh_xcalloc((size_t) (mp->hghsel - mp->lowsel + 2), - sizeof(*smsgs)); + smsgs = mh_xcalloc(mp->hghsel - mp->lowsel + 2, sizeof(*smsgs)); s = smsgs; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {