From: Markus Armbruster Date: Sun, 12 Jun 2005 06:31:48 +0000 (+0000) Subject: Remove a bunch of redundant casts. X-Git-Tag: v4.2.21~59 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=4f59fc9967ed674fa37aa02064b8ff0ea71bfb48 Remove a bunch of redundant casts. --- diff --git a/src/client/ioqueue.c b/src/client/ioqueue.c index 7987a78f2..681857fb9 100644 --- a/src/client/ioqueue.c +++ b/src/client/ioqueue.c @@ -178,7 +178,7 @@ enqueuecc(struct ioqueue *ioq, char *buf, int cc) { struct io *io; - io = (struct io *)malloc(sizeof(*io)); + io = malloc(sizeof(*io)); io->nbytes = cc; io->offset = 0; io->data = buf; diff --git a/src/client/queue.c b/src/client/queue.c index 5b7c67195..2347eef39 100644 --- a/src/client/queue.c +++ b/src/client/queue.c @@ -68,7 +68,7 @@ makeqt(int nelem) struct qelem *qp; int i; - table = (struct qelem *)malloc(sizeof(*table) * nelem); + table = malloc(sizeof(*table) * nelem); for (i = 0, qp = table; i < nelem; i++, qp++) initque(qp); return table; diff --git a/src/client/termio.c b/src/client/termio.c index 49885031e..88bd1551d 100644 --- a/src/client/termio.c +++ b/src/client/termio.c @@ -133,8 +133,8 @@ termio(int fd, int sock, FILE *auxfi) while (p < buf + n && q < out + 4000) { if (*p == '\n') { if (tagging) { - tag = (struct tagstruct *)malloc(sizeof(struct tagstruct)); - tag->item = (char *)malloc((1 + p - s) * sizeof(char)); + tag = malloc(sizeof(struct tagstruct)); + tag->item = malloc((1 + p - s) * sizeof(char)); tag->next = taglist; taglist = tag; t = tag->item; diff --git a/src/lib/as/as_cache.c b/src/lib/as/as_cache.c index 73a7f898f..ca9b62cad 100644 --- a/src/lib/as/as_cache.c +++ b/src/lib/as/as_cache.c @@ -102,7 +102,7 @@ as_add_cachepath(struct as_data *adp) } } else { /* We must make a new one of these */ - from = (struct as_frompath *)malloc(sizeof(struct as_frompath)); + from = malloc(sizeof(struct as_frompath)); if (from == NULL) return; /* And set some stuff */ @@ -115,7 +115,7 @@ as_add_cachepath(struct as_data *adp) } if (!to) { /* We must make a new one */ - to = (struct as_topath *)malloc(sizeof(struct as_topath)); + to = malloc(sizeof(struct as_topath)); /* We can't, sorry */ if (to == NULL) return; @@ -152,15 +152,15 @@ as_clear_cachepath(void) /* Free this path */ as_free_path(to->path); /* Free this node */ - free((s_char *)to); + free(to); } } /* Now, free the list of lists */ - free((s_char *)from->tolist); + free(from->tolist); /* Save the next pointer */ from2 = from->next; /* now, free this from node */ - free((s_char *)from); + free(from); } } /* Note we don't free the fromhead here, we just zero it. That way, diff --git a/src/lib/as/as_delete.c b/src/lib/as/as_delete.c index 39292e5fe..f34a35df2 100644 --- a/src/lib/as/as_delete.c +++ b/src/lib/as/as_delete.c @@ -50,9 +50,9 @@ as_free_queue(struct as_queue *queue) struct as_queue *qp, *qp2; for (qp = queue; qp; qp = qp2) { - free((s_char *)qp->np); + free(qp->np); qp2 = qp->next; - free((s_char *)qp); + free(qp); } } @@ -66,7 +66,7 @@ as_free_path(struct as_path *pp) for (; pp; pp = pp2) { pp2 = pp->next; - free((s_char *)pp); + free(pp); } } @@ -77,8 +77,8 @@ void as_delete(struct as_data *adp) { as_reset(adp); - free((s_char *)adp->neighbor_coords); - free((s_char *)adp->neighbor_nodes); - free((s_char *)adp->hashtab); - free((s_char *)adp); + free(adp->neighbor_coords); + free(adp->neighbor_nodes); + free(adp->hashtab); + free(adp); } diff --git a/src/lib/as/as_hash.c b/src/lib/as/as_hash.c index d9a47f2ef..9311dfc44 100644 --- a/src/lib/as/as_hash.c +++ b/src/lib/as/as_hash.c @@ -74,7 +74,7 @@ as_free_hashtab(struct as_data *adp) for (i = 0; i < adp->hashsize; i++) { for (hp = adp->hashtab[i]; hp; hp = hp2) { hp2 = hp->next; - free((char *)hp); + free(hp); } adp->hashtab[i] = NULL; } diff --git a/src/lib/as/as_search.c b/src/lib/as/as_search.c index ba6188810..f59e025a6 100644 --- a/src/lib/as/as_search.c +++ b/src/lib/as/as_search.c @@ -135,7 +135,7 @@ as_makepath(struct as_data *adp) struct as_node *np; for (np = adp->head->np; np; np = np->back) { - pp = (struct as_path *)malloc(sizeof(struct as_path)); + pp = malloc(sizeof(struct as_path)); pp->c = np->c; pp->next = adp->path; adp->path = pp; diff --git a/src/lib/commands/add.c b/src/lib/commands/add.c index 05de21222..aa2df5c7d 100644 --- a/src/lib/commands/add.c +++ b/src/lib/commands/add.c @@ -143,7 +143,7 @@ add(void) if (p == 0) return RET_OK; snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == coun) { makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y); diff --git a/src/lib/commands/arm.c b/src/lib/commands/arm.c index 32b486890..a411c5887 100644 --- a/src/lib/commands/arm.c +++ b/src/lib/commands/arm.c @@ -101,7 +101,7 @@ arm(void) nuketype = i; nukenum = -1; snxtitem_all(&ni, EF_NUKE); - while (nxtitem(&ni, (s_char *)&nuke)) { + while (nxtitem(&ni, &nuke)) { if (nuke.nuk_own != player->cnum) continue; if (nuke.nuk_x != pl.pln_x || nuke.nuk_y != pl.pln_y) diff --git a/src/lib/commands/boar.c b/src/lib/commands/boar.c index d4e7f5438..10cd85681 100644 --- a/src/lib/commands/boar.c +++ b/src/lib/commands/boar.c @@ -94,7 +94,7 @@ boar(void) /* Look for land units with mobility */ snxtitem_xy(&ni, EF_LAND, off->x, off->y); foundland = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own != player->cnum) continue; if (land.lnd_ship >= 0) diff --git a/src/lib/commands/budg.c b/src/lib/commands/budg.c index e615a5adf..406bb34fd 100644 --- a/src/lib/commands/budg.c +++ b/src/lib/commands/budg.c @@ -241,7 +241,7 @@ calc_all(long p_sect[][2], *planes = *pbuild = *npbuild = *pmaint = 0; np = getnatp(player->cnum); - bp = (int *)calloc(WORLD_X * WORLD_Y * 8, sizeof(int)); + bp = calloc(WORLD_X * WORLD_Y * 8, sizeof(int)); for (n = 0; NULL != (sp = getsectid(n)); n++) { fill_update_array(bp, sp); if (sp->sct_own == player->cnum) { diff --git a/src/lib/commands/buil.c b/src/lib/commands/buil.c index 86e507cd1..7e40e4bff 100644 --- a/src/lib/commands/buil.c +++ b/src/lib/commands/buil.c @@ -387,7 +387,7 @@ build_ship(struct sctstr *sp, struct mchrstr *mp, player->dolcost += cost; cash -= cost; snxtitem_all(&nstr, EF_SHIP); - while (nxtitem(&nstr, (s_char *)&ship)) { + while (nxtitem(&nstr, &ship)) { if (ship.shp_own == 0) { freeship++; break; @@ -527,7 +527,7 @@ build_land(struct sctstr *sp, struct lchrstr *lp, player->dolcost += cost; cash -= cost; snxtitem_all(&nstr, EF_LAND); - while (nxtitem(&nstr, (s_char *)&land)) { + while (nxtitem(&nstr, &land)) { if (land.lnd_own == 0) { freeland++; break; @@ -848,7 +848,7 @@ build_plane(struct sctstr *sp, struct plchrstr *pp, cash -= cost; snxtitem_all(&nstr, EF_PLANE); freeplane = 0; - while (nxtitem(&nstr, (s_char *)&plane)) { + while (nxtitem(&nstr, &plane)) { if (plane.pln_own == 0) { freeplane++; break; diff --git a/src/lib/commands/carg.c b/src/lib/commands/carg.c index 8fd4297bf..46dca5ae4 100644 --- a/src/lib/commands/carg.c +++ b/src/lib/commands/carg.c @@ -51,7 +51,7 @@ carg(void) if (!snxtitem(&ni, EF_SHIP, player->argp[1])) return RET_SYN; nships = 0; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (ship.shp_own == 0) continue; if ((player->cnum != ship.shp_own) && !player->god) @@ -104,7 +104,7 @@ lcarg(void) if (!snxtitem(&ni, EF_LAND, player->argp[1])) return RET_SYN; nunits = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!land.lnd_own) continue; if ((player->cnum != land.lnd_own) && !player->god) diff --git a/src/lib/commands/cede.c b/src/lib/commands/cede.c index 861cc1aae..7e882554a 100644 --- a/src/lib/commands/cede.c +++ b/src/lib/commands/cede.c @@ -158,7 +158,7 @@ cede_sect(struct nstr_sect *ns, natid to) bad = 0; } snxtitem_all(&ni, EF_SHIP); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if ((ship.shp_own == to) && ((ship.shp_x == sect.sct_x) && (ship.shp_y == sect.sct_y))) bad = 0; @@ -300,14 +300,14 @@ cede_ship(struct nstr_item *ni, natid to) int nships = 0; int bad = 0; - while (nxtitem(ni, (s_char *)&ship)) { + while (nxtitem(ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; bad = 1; snxtitem_xy(&tni, EF_SHIP, ship.shp_x, ship.shp_y); - while (nxtitem(&tni, (s_char *)&tship) && bad) + while (nxtitem(&tni, &tship) && bad) if (tship.shp_own == to) bad = 0; diff --git a/src/lib/commands/coas.c b/src/lib/commands/coas.c index cf2df2afd..814e8b023 100644 --- a/src/lib/commands/coas.c +++ b/src/lib/commands/coas.c @@ -76,9 +76,9 @@ coas(void) return RET_SYN; for (i = 0; i < TSIZE; i++) list[i] = 0; - cp = (struct coast *)malloc(sizeof(*cp)); + cp = malloc(sizeof(*cp)); snxtitem_all(&ni, EF_SHIP); - while (nxtitem(&ni, (s_char *)&cp->c_shp)) { + while (nxtitem(&ni, &cp->c_shp)) { if (cp->c_shp.shp_own == 0 || cp->c_shp.shp_own == player->cnum) continue; /* @@ -94,11 +94,11 @@ coas(void) cp->c_number = i; cp->c_next = list[n]; list[n] = cp; - cp = (struct coast *)malloc(sizeof(*cp)); + cp = malloc(sizeof(*cp)); nship++; } /* get that last one! */ - free((s_char *)cp); + free(cp); pr("- = [ Coastwatch report for %s ] = -\n", cname(player->cnum)); pr(" Country Ship Location\n"); tech = tfact(player->cnum, 1.0); @@ -134,7 +134,7 @@ coas(void) for (i = 0; i < TSIZE; i++) { while (NULL != (cp = list[i])) { list[i] = cp->c_next; - free((s_char *)cp); + free(cp); } } return RET_OK; @@ -154,7 +154,7 @@ showship(struct coast **cpp, int x, int y) do { /* we delete it, we free it. */ if (todelete) { - free((s_char *)todelete); + free(todelete); todelete = 0; } if (cp->c_shp.shp_x != x || cp->c_shp.shp_y != y) { @@ -173,6 +173,6 @@ showship(struct coast **cpp, int x, int y) } while (NULL != (cp = cp->c_next)); /* check that last one! */ if (todelete) - free((s_char *)todelete); + free(todelete); return (nship); } diff --git a/src/lib/commands/cons.c b/src/lib/commands/cons.c index 870031f67..51292f4bb 100644 --- a/src/lib/commands/cons.c +++ b/src/lib/commands/cons.c @@ -218,7 +218,7 @@ loan_accept(struct ltcomstr *ltcp) } /* check to see if a loan already exists */ snxtitem_all(&nstr, EF_LOAN); - while (nxtitem(&nstr, (s_char *)&loan)) { + while (nxtitem(&nstr, &loan)) { if (loan.l_status == LS_SIGNED && loan.l_lonee == lp->l_loner && (loan.l_loner == lp->l_lonee)) { pr("He already owes you money - make him repay his loan!\n"); @@ -240,7 +240,7 @@ loan_accept(struct ltcomstr *ltcp) (void)time(&lp->l_lastpay); lp->l_duedate = lp->l_ldur * 86400 + lp->l_lastpay; lp->l_status = LS_SIGNED; - if (!putloan(ltcp->num, (s_char *)lp)) { + if (!putloan(ltcp->num, lp)) { pr("Problem writing lp->to disk; get help!\n"); return RET_FAIL; } diff --git a/src/lib/commands/conv.c b/src/lib/commands/conv.c index 4efa08328..b7929db7f 100644 --- a/src/lib/commands/conv.c +++ b/src/lib/commands/conv.c @@ -97,7 +97,7 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real) * count. */ snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { mil += lnd_getmil(&land); /* mil += (lnd_getmil(&land) * ((double)land.lnd_effic/100.0));*/ diff --git a/src/lib/commands/coun.c b/src/lib/commands/coun.c index 633b524b0..96f643f8e 100644 --- a/src/lib/commands/coun.c +++ b/src/lib/commands/coun.c @@ -57,7 +57,7 @@ coun(void) if (!snxtitem(&ni, EF_NATION, player->argp[1])) return RET_SYN; first = 1; - while (nxtitem(&ni, (s_char *)&nat)) { + while (nxtitem(&ni, &nat)) { if ((nat.nat_stat & STAT_INUSE) == 0) continue; if (((nat.nat_stat & GOD) != GOD) && !player->god) diff --git a/src/lib/commands/decl.c b/src/lib/commands/decl.c index 82f58ef54..8816de8fc 100644 --- a/src/lib/commands/decl.c +++ b/src/lib/commands/decl.c @@ -99,7 +99,7 @@ decl(void) } natp = getnatp(who); - while (nxtitem(&ni, (s_char *)&nat)) { + while (nxtitem(&ni, &nat)) { if (!(nat.nat_stat & STAT_INUSE)) continue; if (player->cnum == (natid)ni.cur) diff --git a/src/lib/commands/drop.c b/src/lib/commands/drop.c index 7ffd22d31..3fdf7206f 100644 --- a/src/lib/commands/drop.c +++ b/src/lib/commands/drop.c @@ -148,7 +148,7 @@ drop(void) && ip->i_vtype == I_SHELL) pln_mine(&bomb_list, &target); else - pln_dropoff(&bomb_list, ip, tx, ty, (s_char *)&target, EF_SECTOR); + pln_dropoff(&bomb_list, ip, tx, ty, &target, EF_SECTOR); } pln_put(&bomb_list); pln_put(&esc_list); diff --git a/src/lib/commands/foll.c b/src/lib/commands/foll.c index d46d56a49..99f35345d 100644 --- a/src/lib/commands/foll.c +++ b/src/lib/commands/foll.c @@ -72,7 +72,7 @@ foll(void) } x = ship.shp_x; y = ship.shp_y; - while (nxtitem(&nstr, (s_char *)&ship)) { + while (nxtitem(&nstr, &ship)) { if (!player->owner) continue; if (ship.shp_x != x || ship.shp_y != y) { diff --git a/src/lib/commands/fort.c b/src/lib/commands/fort.c index d201f6290..433b4ba81 100644 --- a/src/lib/commands/fort.c +++ b/src/lib/commands/fort.c @@ -59,7 +59,7 @@ fort(void) if (fort_amt > land_mob_max) fort_amt = land_mob_max; nunits = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) { diff --git a/src/lib/commands/fuel.c b/src/lib/commands/fuel.c index d3febff17..5ddc7daa7 100644 --- a/src/lib/commands/fuel.c +++ b/src/lib/commands/fuel.c @@ -102,7 +102,7 @@ fuel(void) return RET_FAIL; } - while (nxtitem(&ni, (s_char *)&item)) { + while (nxtitem(&ni, &item)) { fueled = 0; if (type == EF_SHIP) { if (item.ship.shp_own != player->cnum) { @@ -222,7 +222,7 @@ fuel(void) if (!check_ship_ok(&item.ship)) continue; - if (!nxtitem(&tender, (s_char *)&item2)) + if (!nxtitem(&tender, &item2)) continue; if (!(mchr[(int)item2.ship.shp_type].m_flags & M_OILER)) { @@ -384,7 +384,7 @@ fuel(void) if (!check_land_ok(&item.land)) continue; - if (!nxtitem(<ender, (s_char *)&item2)) + if (!nxtitem(<ender, &item2)) continue; if (!(lchr[(int)item2.land.lnd_type].l_flags & L_SUPPLY)) { diff --git a/src/lib/commands/hard.c b/src/lib/commands/hard.c index ff0577a26..367f8a9a6 100644 --- a/src/lib/commands/hard.c +++ b/src/lib/commands/hard.c @@ -71,7 +71,7 @@ hard(void) return RET_SYN; natp = getnatp(player->cnum); cash = natp->nat_money; - while (nxtitem(&ni, (s_char *)&pln)) { + while (nxtitem(&ni, &pln)) { if (!player->owner) continue; pcp = &plchr[(int)pln.pln_type]; diff --git a/src/lib/commands/head.c b/src/lib/commands/head.c index 296df49b9..0f29fdbdc 100644 --- a/src/lib/commands/head.c +++ b/src/lib/commands/head.c @@ -93,7 +93,7 @@ head(void) memset(hist, 0, sizeof(hist)); snxtitem_all(&nstr, EF_NEWS); maxcnum = 0; - while (nxtitem(&nstr, (s_char *)&news)) { + while (nxtitem(&nstr, &news)) { news_age = now - news.nws_when; if (news_age > news_per) continue; diff --git a/src/lib/commands/info.c b/src/lib/commands/info.c index e171b7ec6..c12c27ccf 100644 --- a/src/lib/commands/info.c +++ b/src/lib/commands/info.c @@ -199,9 +199,9 @@ apro(void) return RET_SYS; } - fbuf = (s_char *)malloc(256); - lbuf = (s_char *)malloc(256); - lbp = (s_char *)malloc(256); + fbuf = malloc(256); + lbuf = malloc(256); + lbp = malloc(256); /* * lower case search string into lbp @@ -434,9 +434,9 @@ apro(void) return RET_SYS; } - fbuf = (s_char *)malloc(256); - lbuf = (s_char *)malloc(256); - lbp = (s_char *)malloc(256); + fbuf = malloc(256); + lbuf = malloc(256); + lbp = malloc(256); /* * lower case search string into lbp diff --git a/src/lib/commands/land.c b/src/lib/commands/land.c index 22de5ae59..5469c3ca8 100644 --- a/src/lib/commands/land.c +++ b/src/lib/commands/land.c @@ -51,7 +51,7 @@ land(void) return RET_SYN; nunits = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (!player->owner && !player->god) diff --git a/src/lib/commands/laun.c b/src/lib/commands/laun.c index 6e3435bac..c7da7db70 100644 --- a/src/lib/commands/laun.c +++ b/src/lib/commands/laun.c @@ -70,7 +70,7 @@ laun(void) if (!snxtitem(&nstr, EF_PLANE, player->argp[1])) return RET_SYN; - while (nxtitem(&nstr, (s_char *)&plane)) { + while (nxtitem(&nstr, &plane)) { if (plane.pln_own != player->cnum) continue; pcp = &plchr[(int)plane.pln_type]; diff --git a/src/lib/commands/ldump.c b/src/lib/commands/ldump.c index b38ed18bf..61466920b 100644 --- a/src/lib/commands/ldump.c +++ b/src/lib/commands/ldump.c @@ -289,7 +289,7 @@ ldump(void) pr("\n"); np = getnatp(player->cnum); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (!player->owner && !player->god) diff --git a/src/lib/commands/ledg.c b/src/lib/commands/ledg.c index 61e849895..938c05fdf 100644 --- a/src/lib/commands/ledg.c +++ b/src/lib/commands/ledg.c @@ -56,7 +56,7 @@ ledg(void) return RET_SYN; pr("\n... %s Ledger ...\n", cname(player->cnum)); nloan = 0; - while (nxtitem(&nstr, (s_char *)&loan)) { + while (nxtitem(&nstr, &loan)) { if (disloan(nstr.cur, &loan) > 0) nloan++; } diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index fc09e5627..ead2aa64a 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -112,7 +112,7 @@ load(void) load_unload = **player->argp == 'l' ? LOAD : UNLOAD; nships = 0; - while (nxtitem(&nbst, (s_char *)&ship)) { + while (nxtitem(&nbst, &ship)) { if (!ship.shp_own) continue; if (!player->owner && (load_unload == UNLOAD)) { @@ -250,7 +250,7 @@ lload(void) load_unload = *(*player->argp + 1) == 'l' ? LOAD : UNLOAD; nunits = 0; - while (nxtitem(&nbst, (s_char *)&land)) { + while (nxtitem(&nbst, &land)) { if (land.lnd_own == 0) continue; @@ -402,7 +402,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, if (p && *p) noisy &= isdigit(*p); - while (nxtitem(&ni, (s_char *)&pln)) { + while (nxtitem(&ni, &pln)) { if (pln.pln_own != player->cnum) continue; if (!(plchr[(int)pln.pln_type].pl_flags & P_L) @@ -547,7 +547,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, if (p && *p) noisy &= isdigit(*p); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own != player->cnum) continue; @@ -656,7 +656,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, pr("WARNING: %s is out of supply!\n", prland(&land)); putship(sp->shp_uid, sp); snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y); - while (nxtitem(&pni, (s_char *)&plane)) { + while (nxtitem(&pni, &plane)) { if (plane.pln_flags & PLN_LAUNCHED) continue; if (plane.pln_land != land.lnd_uid) @@ -698,7 +698,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, they are quietly unloaded too. */ if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) { snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y); - while (nxtitem(&pni, (s_char *)&plane)) { + while (nxtitem(&pni, &plane)) { if (plane.pln_flags & PLN_LAUNCHED) continue; if (plane.pln_land != land.lnd_uid) @@ -857,7 +857,7 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy, return 0; } - while (nxtitem(&ni, (s_char *)&pln)) { + while (nxtitem(&ni, &pln)) { if (pln.pln_own != player->cnum) continue; @@ -1059,7 +1059,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, if (p && *p) noisy &= isdigit(*p); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own != player->cnum) continue; @@ -1136,7 +1136,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, pr("WARNING: %s is out of supply!\n", prland(&land)); putland(lp->lnd_uid, lp); snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y); - while (nxtitem(&pni, (s_char *)&plane)) { + while (nxtitem(&pni, &plane)) { if (plane.pln_flags & PLN_LAUNCHED) continue; if (plane.pln_land != land.lnd_uid) @@ -1168,7 +1168,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, putland(land.lnd_uid, &land); putland(lp->lnd_uid, lp); snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y); - while (nxtitem(&pni, (s_char *)&plane)) { + while (nxtitem(&pni, &plane)) { if (plane.pln_flags & PLN_LAUNCHED) continue; if (plane.pln_land != land.lnd_uid) diff --git a/src/lib/commands/look.c b/src/lib/commands/look.c index 579c8f4ed..5d2e8d97d 100644 --- a/src/lib/commands/look.c +++ b/src/lib/commands/look.c @@ -63,13 +63,13 @@ look(void) if (!snxtitem(&ni, EF_SHIP, player->argp[1])) return RET_SYN; - if ((bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8)) == 0) { + if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) { logerror("malloc failed in look\n"); pr("Memory error. Tell the deity.\n"); return RET_FAIL; } memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); - while (nxtitem(&ni, (s_char *)&myship)) { + while (nxtitem(&ni, &myship)) { if (!player->owner) continue; look_ship(&myship); @@ -107,7 +107,7 @@ look(void) } if (changed) writemap(player->cnum); - free((s_char *)bitmap); + free(bitmap); return RET_OK; } @@ -188,13 +188,13 @@ llook(void) if (!snxtitem(&ni, EF_LAND, player->argp[1])) return RET_SYN; - if ((bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8)) == 0) { + if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) { logerror("malloc failed in llook\n"); pr("Memory error. Tell the deity.\n"); return RET_FAIL; } memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); - while (nxtitem(&ni, (s_char *)&myland)) { + while (nxtitem(&ni, &myland)) { if (!player->owner) continue; if (myland.lnd_ship >= 0) @@ -241,7 +241,7 @@ llook(void) } if (changed) writemap(player->cnum); - free((s_char *)bitmap); + free(bitmap); return RET_OK; } diff --git a/src/lib/commands/lost.c b/src/lib/commands/lost.c index e1d99e56c..e6740d372 100644 --- a/src/lib/commands/lost.c +++ b/src/lib/commands/lost.c @@ -60,7 +60,7 @@ lost(void) if (player->god) pr("owner "); pr("type id x y timestamp\n"); - while (nxtitem(&ni, (s_char *)&lost)) { + while (nxtitem(&ni, &lost)) { if (lost.lost_owner == 0) continue; if (lost.lost_owner != player->cnum && !player->god) diff --git a/src/lib/commands/lstat.c b/src/lib/commands/lstat.c index 75900f582..b18c66302 100644 --- a/src/lib/commands/lstat.c +++ b/src/lib/commands/lstat.c @@ -49,7 +49,7 @@ lsta(void) return RET_SYN; nunits = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) { diff --git a/src/lib/commands/lten.c b/src/lib/commands/lten.c index bbce04612..8fd2d5fe6 100644 --- a/src/lib/commands/lten.c +++ b/src/lib/commands/lten.c @@ -74,7 +74,7 @@ ltend(void) if (!snxtitem(&tenders, EF_SHIP, getstarg(player->argp[2], "Tender(s)? ", buf))) return RET_SYN; - while (nxtitem(&tenders, (s_char *)&tender)) { + while (nxtitem(&tenders, &tender)) { if (!player->owner) continue; if ((p = @@ -103,7 +103,7 @@ ltend(void) if (!check_ship_ok(&tender)) return RET_FAIL; total = 0; - while (nxtitem(&targets, (s_char *)&target)) { + while (nxtitem(&targets, &target)) { if (!player->owner) continue; diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index 96e8e3a57..8fbcba828 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -158,7 +158,7 @@ multifire(void) pr("Fire aborted.\n"); return RET_OK; } - while (nxtitem(&nbst, (s_char *)&item)) { + while (nxtitem(&nbst, &item)) { attacker = orig_attacker; if (attacker == targ_unit) { if (!getland(item.land.lnd_uid, &fland)) @@ -674,7 +674,7 @@ defend(struct emp_qelem *al, struct emp_qelem *dl, enum targ_type target, (dam = quiet_bigdef(attacker, dl, vict, aown, fx, fy, &nfiring))) { if (nfiring > *nd) *nd = nfiring; - fp = (struct flist *)malloc(sizeof(struct flist)); + fp = malloc(sizeof(struct flist)); memset(fp, 0, sizeof(struct flist)); fp->defdam = dam; fp->victim = vict; @@ -742,7 +742,7 @@ do_defdam(struct emp_qelem *list, double odds) xyas(fp->x, fp->y, vict), dam); } emp_remque(&fp->queue); - free((s_char *)fp); + free(fp); } } @@ -813,7 +813,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, continue; (*nfiring)++; - fp = (struct flist *)malloc(sizeof(struct flist)); + fp = malloc(sizeof(struct flist)); memset(fp, 0, sizeof(struct flist)); fp->type = targ_ship; fp->uid = ship.shp_uid; @@ -844,7 +844,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, if (nshot == 0) continue; (*nfiring)++; - fp = (struct flist *)malloc(sizeof(struct flist)); + fp = malloc(sizeof(struct flist)); memset(fp, 0, sizeof(struct flist)); fp->type = targ_ship; fp->uid = ship.shp_uid; @@ -897,7 +897,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, land.lnd_ammo, shell); (*nfiring)++; - fp = (struct flist *)malloc(sizeof(struct flist)); + fp = malloc(sizeof(struct flist)); memset(fp, 0, sizeof(struct flist)); fp->type = targ_unit; fp->uid = land.lnd_uid; @@ -950,7 +950,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, if (gun == 0 || firing.sct_item[I_MILIT] < 5 || shell == 0) continue; (*nfiring)++; - fp = (struct flist *)malloc(sizeof(struct flist)); + fp = malloc(sizeof(struct flist)); memset(fp, 0, sizeof(struct flist)); fp->x = firing.sct_x; fp->y = firing.sct_y; @@ -1021,7 +1021,7 @@ use_ammo(struct emp_qelem *list) putland(land.lnd_uid, &land); emp_remque(&fp->queue); - free((s_char *)fp); + free(fp); } } diff --git a/src/lib/commands/mine.c b/src/lib/commands/mine.c index ba58408d4..b01618e79 100644 --- a/src/lib/commands/mine.c +++ b/src/lib/commands/mine.c @@ -62,7 +62,7 @@ mine(void) "Drop how many mines from each ship? "); if (mines <= 0) return RET_SYN; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner) continue; mp = &mchr[(int)ship.shp_type]; @@ -107,7 +107,7 @@ landmine(void) if (!snxtitem(&ni, EF_LAND, player->argp[1])) return RET_SYN; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner) continue; lp = &lchr[(int)land.lnd_type]; diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index fad95990a..9dfb982ad 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -190,7 +190,7 @@ mission(void) size = max(sizeof(struct lndstr), sizeof(struct plnstr)); size = max(size, sizeof(struct shpstr)); - block = (s_char *)malloc(size); + block = malloc(size); switch (type) { case EF_SHIP: mobmax = ship_mob_max; diff --git a/src/lib/commands/mobq.c b/src/lib/commands/mobq.c index 739826b7b..03d2fee99 100644 --- a/src/lib/commands/mobq.c +++ b/src/lib/commands/mobq.c @@ -72,7 +72,7 @@ mobq(void) pr("warning: %d less than optimal\n", mobquota); } } - while (nxtitem(&nstr, (s_char *)&ship)) { + while (nxtitem(&nstr, &ship)) { if (!player->owner) continue; if (!oldmq) diff --git a/src/lib/commands/mora.c b/src/lib/commands/mora.c index 0c8ed8382..0f94cda37 100644 --- a/src/lib/commands/mora.c +++ b/src/lib/commands/mora.c @@ -54,7 +54,7 @@ morale(void) if (!snxtitem(&np, EF_LAND, player->argp[1])) return RET_SYN; - while (!player->aborted && nxtitem(&np, (s_char *)&land)) { + while (!player->aborted && nxtitem(&np, &land)) { if (!player->owner || land.lnd_own == 0) continue; natp = getnatp(land.lnd_own); diff --git a/src/lib/commands/name.c b/src/lib/commands/name.c index 25175415b..8a01326db 100644 --- a/src/lib/commands/name.c +++ b/src/lib/commands/name.c @@ -57,7 +57,7 @@ name(void) } if (!snxtitem(&nb, EF_SHIP, player->argp[1])) return RET_SYN; - while (nxtitem(&nb, (s_char *)&ship)) { + while (nxtitem(&nb, &ship)) { if (!player->owner) continue; p = getstarg(player->argp[2], "Name? ", buf); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 022f27c8d..61adf5e3a 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -237,20 +237,19 @@ nav_map(int x, int y, int show_designations) if (!snxtsct(&ns, what)) return RET_FAIL; if (!wmapbuf) - wmapbuf = - (s_char *)malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); if (!wmap) { - wmap = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + wmap = malloc(WORLD_Y * sizeof(s_char *)); if (wmap && wmapbuf) { for (i = 0; i < WORLD_Y; i++) wmap[i] = &wmapbuf[MAPWIDTH(1) * i]; } else if (wmap) { - free((s_char *)wmap); + free(wmap); wmap = (s_char **)0; } } if (!bitmap) - bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8); + bitmap = malloc((WORLD_X * WORLD_Y) / 8); if (!wmapbuf || !wmap || !bitmap) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in navi\n"); diff --git a/src/lib/commands/ndump.c b/src/lib/commands/ndump.c index 10e7b6b62..ddd36aef6 100644 --- a/src/lib/commands/ndump.c +++ b/src/lib/commands/ndump.c @@ -59,7 +59,7 @@ ndump(void) pr("own "); pr("id x y num type\n"); nnukes = 0; - while (nxtitem(&nstr, (s_char *)&nuk)) { + while (nxtitem(&nstr, &nuk)) { if (!player->god && !player->owner) continue; if (nuk.nuk_own == 0) diff --git a/src/lib/commands/new.c b/src/lib/commands/new.c index 53558f3ad..8a7927162 100644 --- a/src/lib/commands/new.c +++ b/src/lib/commands/new.c @@ -229,14 +229,14 @@ isok(int x, int y) nmin = ngold = noil = nur = 0; navail = nfree = nowned = 0; - if ((map = (s_char *)malloc((WORLD_X * WORLD_Y) / 2)) == 0) { + if ((map = malloc((WORLD_X * WORLD_Y) / 2)) == 0) { logerror("malloc failed in isok\n"); pr("Memory error. Tell the deity.\n"); return 0; } memset(map, 0, (WORLD_X * WORLD_Y) / 2); ok(map, x, y); - free((s_char *)map); + free(map); if (nfree < 5) return 0; pr("Cap at %s; owned sectors: %d, free sectors: %d, avail: %d\n", @@ -261,7 +261,7 @@ ok(s_char *map, int x, int y) id = sctoff(x, y); if (map[id]) return; - if (!ef_read(EF_SECTOR, id, (s_char *)§)) + if (!ef_read(EF_SECTOR, id, §)) return; if (sect.sct_type == SCT_WATER || sect.sct_type == SCT_BSPAN) return; @@ -302,7 +302,7 @@ deity_build_land(int type, coord x, coord y, natid own, int tlev) natp = getnatp(own); snxtitem_all(&nstr, EF_LAND); - while (nxtitem(&nstr, (s_char *)&land)) { + while (nxtitem(&nstr, &land)) { if (land.lnd_own == 0) { extend = 0; break; diff --git a/src/lib/commands/news.c b/src/lib/commands/news.c index bd440bd24..830188b77 100644 --- a/src/lib/commands/news.c +++ b/src/lib/commands/news.c @@ -89,7 +89,7 @@ news(void) then = now - days(3); */ pr("\nThe details of Empire news since %s", ctime(&then)); - while (nxtitem(&nstr, (s_char *)&nws)) { + while (nxtitem(&nstr, &nws)) { if (nws.nws_when < then) continue; if (opt_HIDDEN) { @@ -106,7 +106,7 @@ news(void) continue; pr("\n\t === %s ===\n", page_headings[page]); snxtitem_rewind(&nstr); - while (nxtitem(&nstr, (s_char *)&nws)) { + while (nxtitem(&nstr, &nws)) { if (rpt[(int)nws.nws_vrb].r_newspage != page) continue; if (nws.nws_when < then) diff --git a/src/lib/commands/nuke.c b/src/lib/commands/nuke.c index 7a9a76b13..07a821265 100644 --- a/src/lib/commands/nuke.c +++ b/src/lib/commands/nuke.c @@ -55,7 +55,7 @@ nuke(void) if (!snxtitem(&nstr, EF_NUKE, player->argp[1])) return RET_SYN; - while (nxtitem(&nstr, (s_char *)&nuk)) { + while (nxtitem(&nstr, &nuk)) { if (!player->god && !player->owner) continue; if (nuk.nuk_own == 0) diff --git a/src/lib/commands/offe.c b/src/lib/commands/offe.c index 3b8589b99..1c3abed85 100644 --- a/src/lib/commands/offe.c +++ b/src/lib/commands/offe.c @@ -135,7 +135,7 @@ do_treaty(void) } (void)time(&now); snxtitem_all(&nstr, EF_TREATY); - while (nxtitem(&nstr, (s_char *)&trty)) { + while (nxtitem(&nstr, &trty)) { if (trty.trt_status == TS_FREE) { break; } @@ -212,7 +212,7 @@ do_loan(void) if (irate < 5) return RET_FAIL; snxtitem_all(&nstr, EF_LOAN); - while (nxtitem(&nstr, (s_char *)&loan)) { + while (nxtitem(&nstr, &loan)) { if ((loan.l_status == LS_SIGNED) && (loan.l_lonee == player->cnum) && (loan.l_loner == recipient)) { pr("You already owe HIM money - how about repaying your loan?\n"); @@ -220,7 +220,7 @@ do_loan(void) } } snxtitem_all(&nstr, EF_LOAN); - while (nxtitem(&nstr, (s_char *)&loan)) { + while (nxtitem(&nstr, &loan)) { if (loan.l_status == LS_FREE) break; } diff --git a/src/lib/commands/orde.c b/src/lib/commands/orde.c index ad0dba7e7..c253294bb 100644 --- a/src/lib/commands/orde.c +++ b/src/lib/commands/orde.c @@ -83,7 +83,7 @@ orde(void) if (!snxtitem(&nb, EF_SHIP, player->argp[1])) return RET_SYN; - while (!player->aborted && nxtitem(&nb, (s_char *)(&ship))) { + while (!player->aborted && nxtitem(&nb, (&ship))) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { @@ -370,7 +370,7 @@ qorde(void) if (!snxtitem(&nb, EF_SHIP, player->argp[1])) return RET_SYN; - while (nxtitem(&nb, (s_char *)(&ship))) { + while (nxtitem(&nb, (&ship))) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { @@ -444,7 +444,7 @@ sorde(void) if (!snxtitem(&nb, EF_SHIP, player->argp[1])) return RET_SYN; - while (nxtitem(&nb, (s_char *)(&ship))) { + while (nxtitem(&nb, (&ship))) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { diff --git a/src/lib/commands/path.c b/src/lib/commands/path.c index c18fe0f60..9748a0cef 100644 --- a/src/lib/commands/path.c +++ b/src/lib/commands/path.c @@ -80,15 +80,14 @@ path(void) return RET_FAIL; } if (!mapbuf) - mapbuf = - (s_char *)malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); + mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); if (!map) { - map = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { for (i = 0; i < WORLD_Y; i++) map[i] = &mapbuf[MAPWIDTH(3) * i]; } else if (map) { - free((s_char *)map); + free(map); map = (s_char **)0; } } diff --git a/src/lib/commands/payo.c b/src/lib/commands/payo.c index 37c54adf2..b73a16b33 100644 --- a/src/lib/commands/payo.c +++ b/src/lib/commands/payo.c @@ -61,7 +61,7 @@ payo(void) return RET_SYN; nships = 0; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { diff --git a/src/lib/commands/pboa.c b/src/lib/commands/pboa.c index b95a9de2f..38148e93a 100644 --- a/src/lib/commands/pboa.c +++ b/src/lib/commands/pboa.c @@ -46,7 +46,7 @@ pboa(void) if (!snxtitem(&np, EF_PLANE, player->argp[1])) return RET_SYN; - while (nxtitem(&np, (s_char *)&plane)) { + while (nxtitem(&np, &plane)) { getsect(plane.pln_x, plane.pln_y, §); if (sect.sct_own != player->cnum) continue; diff --git a/src/lib/commands/pdump.c b/src/lib/commands/pdump.c index 8d038b469..ac9d1f3e8 100644 --- a/src/lib/commands/pdump.c +++ b/src/lib/commands/pdump.c @@ -200,7 +200,7 @@ pdump(void) nplanes = 0; natp = getnatp(player->cnum); - while (nxtitem(&np, (s_char *)&plane)) { + while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; nplanes++; diff --git a/src/lib/commands/plan.c b/src/lib/commands/plan.c index 46563e3a8..66d43048f 100644 --- a/src/lib/commands/plan.c +++ b/src/lib/commands/plan.c @@ -51,7 +51,7 @@ plan(void) if (!snxtitem(&np, EF_PLANE, player->argp[1])) return RET_SYN; nplanes = 0; - while (nxtitem(&np, (s_char *)&plane)) { + while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; if (nplanes++ == 0) { diff --git a/src/lib/commands/powe.c b/src/lib/commands/powe.c index c2f167bc7..8011ad1ae 100644 --- a/src/lib/commands/powe.c +++ b/src/lib/commands/powe.c @@ -124,7 +124,7 @@ powe(void) if (!power_generated) { snxtitem_all(&ni, EF_POWER); - if (!nxtitem(&ni, (s_char *)&pow)) { + if (!nxtitem(&ni, &pow)) { pr("Power for this game has not been built yet. Type 'power new' to build it.\n"); return RET_FAIL; } @@ -134,7 +134,7 @@ powe(void) pr(" as of %s\n sects eff civ", ctime(&pow_time)); pr(" mil shell gun pet iron dust oil pln ship unit money\n"); snxtitem_all(&ni, EF_POWER); - while ((nxtitem(&ni, (s_char *)&pow)) && num > 0) { + while ((nxtitem(&ni, &pow)) && num > 0) { if (pow.p_nation == 0 || pow.p_power <= 0.0) continue; if (opt_HIDDEN) { @@ -251,7 +251,7 @@ gen_power(void) addtopow(sect.sct_item, pow); } snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; pow = &powbuf[land.lnd_own]; @@ -262,7 +262,7 @@ gen_power(void) pow->p_units += 1.0; } snxtitem_all(&ni, EF_SHIP); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (ship.shp_own == 0) continue; pow = &powbuf[ship.shp_own]; @@ -273,7 +273,7 @@ gen_power(void) pow->p_ships += 1.0; } snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; pow = &powbuf[plane.pln_own]; diff --git a/src/lib/commands/pstat.c b/src/lib/commands/pstat.c index 081e56f65..08c32593c 100644 --- a/src/lib/commands/pstat.c +++ b/src/lib/commands/pstat.c @@ -49,7 +49,7 @@ pstat(void) if (!snxtitem(&np, EF_PLANE, player->argp[1])) return RET_SYN; nplanes = 0; - while (nxtitem(&np, (s_char *)&plane)) { + while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; if (plane.pln_type < 0 || plane.pln_type > pln_maxno) { diff --git a/src/lib/commands/rada.c b/src/lib/commands/rada.c index 83e19e672..ab354f1fe 100644 --- a/src/lib/commands/rada.c +++ b/src/lib/commands/rada.c @@ -94,7 +94,7 @@ rada(void) pr("Specify at least one ship\n"); return RET_SYN; } - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner) continue; if (mchr[(int)ship.shp_type].m_flags & M_SONAR) @@ -117,7 +117,7 @@ rada(void) pr("Specify at least one unit\n"); return RET_SYN; } - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner) continue; if (!(lchr[(int)land.lnd_type].l_flags & L_RADAR)) { diff --git a/src/lib/commands/rang.c b/src/lib/commands/rang.c index 546000cc8..47d633691 100644 --- a/src/lib/commands/rang.c +++ b/src/lib/commands/rang.c @@ -50,7 +50,7 @@ range(void) if (!snxtitem(&np, EF_PLANE, player->argp[1])) return RET_SYN; - while (nxtitem(&np, (s_char *)&plane)) { + while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; p = getstarg(player->argp[2], "New range? ", buf); @@ -82,7 +82,7 @@ lrange(void) if (!snxtitem(&np, EF_LAND, player->argp[1])) return RET_SYN; - while (nxtitem(&np, (s_char *)&land)) { + while (nxtitem(&np, &land)) { if (!player->owner || land.lnd_own == 0) continue; lcp = &lchr[(int)land.lnd_type]; diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c index 2ec7d54b0..047d614a7 100644 --- a/src/lib/commands/rea.c +++ b/src/lib/commands/rea.c @@ -117,7 +117,7 @@ rea(void) lastdate = 0; lastcnum = -1; lasttype = -1; - while (fread((s_char *)&tgm, sizeof(tgm), 1, telfp) == 1) { + while (fread(&tgm, sizeof(tgm), 1, telfp) == 1) { readit = 1; if (tgm.tel_length < 0) { logerror("bad telegram file header in %s", mbox); diff --git a/src/lib/commands/reje.c b/src/lib/commands/reje.c index 5465fba73..30e983c24 100644 --- a/src/lib/commands/reje.c +++ b/src/lib/commands/reje.c @@ -86,7 +86,7 @@ reje(void) } if (!snxtitem(&ni, EF_NATION, player->argp[3])) return RET_SYN; - while (nxtitem(&ni, (s_char *)&nat)) { + while (nxtitem(&ni, &nat)) { #if 0 if ((nat.nat_stat & STAT_NORM) == 0) { pr("You may not reject/accept stuff from %s\nbecause they are not a normal country.\n", nat.nat_cnam); diff --git a/src/lib/commands/repo.c b/src/lib/commands/repo.c index a64391e67..fced03fec 100644 --- a/src/lib/commands/repo.c +++ b/src/lib/commands/repo.c @@ -88,7 +88,7 @@ repo(void) } else { first = 1; } - while (nxtitem(&ni, (s_char *)&nat)) { + while (nxtitem(&ni, &nat)) { if (!(nat.nat_stat & STAT_INUSE)) continue; if (opt_HIDDEN) { diff --git a/src/lib/commands/retr.c b/src/lib/commands/retr.c index e92bbc4c4..6b6d3b9a5 100644 --- a/src/lib/commands/retr.c +++ b/src/lib/commands/retr.c @@ -132,7 +132,7 @@ retr(void) if (zero) rflags = 0; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { @@ -261,7 +261,7 @@ lretr(void) if (zero) rflags = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) { diff --git a/src/lib/commands/rout.c b/src/lib/commands/rout.c index ac19b5774..2a123b7fd 100644 --- a/src/lib/commands/rout.c +++ b/src/lib/commands/rout.c @@ -88,20 +88,19 @@ rout(void) } else if (!snxtsct(&ns, str)) return RET_FAIL; if (!mapbuf) - mapbuf = - (s_char *)malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); + mapbuf = malloc((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char)); if (!map) { - map = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { for (i = 0; i < WORLD_Y; i++) map[i] = &mapbuf[MAPWIDTH(3) * i]; } else if (map) { - free((s_char *)map); + free(map); map = (s_char **)0; } } if (!buf) - buf = (s_char *)malloc((MAPWIDTH(3) + 12) * sizeof(s_char)); + buf = malloc((MAPWIDTH(3) + 12) * sizeof(s_char)); if (!mapbuf || !map || !buf) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in rout\n"); diff --git a/src/lib/commands/sabo.c b/src/lib/commands/sabo.c index 829633a5d..af21f9e00 100644 --- a/src/lib/commands/sabo.c +++ b/src/lib/commands/sabo.c @@ -49,7 +49,7 @@ sabo(void) if (!snxtitem(&ni, EF_LAND, player->argp[1])) return RET_SYN; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner) continue; if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) { diff --git a/src/lib/commands/sail.c b/src/lib/commands/sail.c index 809c09922..3c50f8533 100644 --- a/src/lib/commands/sail.c +++ b/src/lib/commands/sail.c @@ -48,7 +48,7 @@ show_sail(struct nstr_item *nstr) int count = 0; struct shpstr ship; - while (nxtitem(nstr, (s_char *)&ship)) { + while (nxtitem(nstr, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { @@ -100,7 +100,7 @@ cmd_unsail_ship(struct nstr_item *nstr) struct shpstr ship; int count = 0; - while (nxtitem(nstr, (s_char *)&ship)) { + while (nxtitem(nstr, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { @@ -124,7 +124,7 @@ cmd_sail_ship(struct nstr_item *nstr) struct shpstr ship; char navpath[MAX_PATH_LEN]; - while (!player->aborted && nxtitem(nstr, (s_char *)&ship)) { + while (!player->aborted && nxtitem(nstr, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { diff --git a/src/lib/commands/scra.c b/src/lib/commands/scra.c index 92e6d68aa..ed675bbf9 100644 --- a/src/lib/commands/scra.c +++ b/src/lib/commands/scra.c @@ -136,7 +136,7 @@ scra(void) if (!confirm(y_or_n)) return RET_FAIL; } - while (nxtitem(&ni, (s_char *)&item)) { + while (nxtitem(&ni, &item)) { if (!player->owner) continue; @@ -192,7 +192,7 @@ scra(void) sect.sct_item[I_HCM] += mp->m_hcm * 2 / 3 * eff; getsect(item.ship.shp_x, item.ship.shp_y, §2); snxtitem_all(&ni2, EF_PLANE); - while (nxtitem(&ni2, (s_char *)&plane)) { + while (nxtitem(&ni2, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_ship == item.ship.shp_uid) { @@ -214,11 +214,11 @@ scra(void) plane.pln_own = sect2.sct_own; makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x, plane.pln_y); - putplane(plane.pln_uid, (s_char *)&plane); + putplane(plane.pln_uid, &plane); } } snxtitem_all(&ni2, EF_LAND); - while (nxtitem(&ni2, (s_char *)&land)) { + while (nxtitem(&ni2, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_ship == item.ship.shp_uid) { @@ -240,13 +240,13 @@ scra(void) land.lnd_own = sect2.sct_own; makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y); - putland(land.lnd_uid, (s_char *)&land); + putland(land.lnd_uid, &land); } } makelost(EF_SHIP, item.ship.shp_own, item.ship.shp_uid, item.ship.shp_x, item.ship.shp_y); item.ship.shp_own = 0; - putship(item.ship.shp_uid, (s_char *)&item.ship); + putship(item.ship.shp_uid, &item.ship); } else if (type == EF_LAND) { eff = ((float)item.land.lnd_effic / 100.0); lp = &lchr[(int)item.land.lnd_type]; @@ -259,7 +259,7 @@ scra(void) getsect(item.land.lnd_x, item.land.lnd_y, §2); snxtitem_all(&ni2, EF_LAND); - while (nxtitem(&ni2, (s_char *)&land)) { + while (nxtitem(&ni2, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_land == item.land.lnd_uid) { @@ -281,12 +281,12 @@ scra(void) land.lnd_own = sect2.sct_own; makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y); - putland(land.lnd_uid, (s_char *)&land); + putland(land.lnd_uid, &land); } } snxtitem_all(&ni2, EF_PLANE); - while (nxtitem(&ni2, (s_char *)&plane)) { + while (nxtitem(&ni2, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_land == item.land.lnd_uid) { @@ -308,13 +308,13 @@ scra(void) plane.pln_own = sect2.sct_own; makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x, plane.pln_y); - putplane(plane.pln_uid, (s_char *)&plane); + putplane(plane.pln_uid, &plane); } } makelost(EF_LAND, item.land.lnd_own, item.land.lnd_uid, item.land.lnd_x, item.land.lnd_y); item.land.lnd_own = 0; - putland(item.land.lnd_uid, (s_char *)&item.land); + putland(item.land.lnd_uid, &item.land); } else { eff = ((float)item.land.lnd_effic / 100.0); pp = &plchr[(int)item.plane.pln_type]; @@ -325,7 +325,7 @@ scra(void) makelost(EF_PLANE, item.plane.pln_own, item.plane.pln_uid, item.plane.pln_x, item.plane.pln_y); item.plane.pln_own = 0; - putplane(item.plane.pln_uid, (s_char *)&item.plane); + putplane(item.plane.pln_uid, &item.plane); } pr(" scrapped in %s\n", xyas(sect.sct_x, sect.sct_y, player->cnum)); diff --git a/src/lib/commands/scut.c b/src/lib/commands/scut.c index b8a016057..d4069be0a 100644 --- a/src/lib/commands/scut.c +++ b/src/lib/commands/scut.c @@ -203,7 +203,7 @@ scut(void) if (!confirm(y_or_n)) return RET_FAIL; } - while (nxtitem(&ni, (s_char *)&item)) { + while (nxtitem(&ni, &item)) { if (!player->owner) continue; if (opt_MARKET) { @@ -241,7 +241,7 @@ scut(void) makelost(EF_PLANE, item.plane.pln_own, item.plane.pln_uid, item.plane.pln_x, item.plane.pln_y); item.plane.pln_own = 0; - putplane(item.plane.pln_uid, (s_char *)&item.plane); + putplane(item.plane.pln_uid, &item.plane); } pr(" scuttled in %s\n", xyas(item.ship.shp_x, item.ship.shp_y, player->cnum)); @@ -260,7 +260,7 @@ scuttle_ship(struct shpstr *sp) getsect(sp->shp_x, sp->shp_y, §); snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_ship == sp->shp_uid) { @@ -278,11 +278,11 @@ scuttle_ship(struct shpstr *sp) plane.pln_uid, sp->shp_uid, xyas(plane.pln_x, plane.pln_y, plane.pln_own)); } - putplane(plane.pln_uid, (s_char *)&plane); + putplane(plane.pln_uid, &plane); } } snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_ship == sp->shp_uid) { @@ -292,7 +292,7 @@ scuttle_ship(struct shpstr *sp) "Land unit %d transferred off ship %d to %s\n", land.lnd_uid, sp->shp_uid, xyas(land.lnd_x, land.lnd_y, land.lnd_own)); - putland(land.lnd_uid, (s_char *)&land); + putland(land.lnd_uid, &land); } else scuttle_land(&land); } @@ -312,7 +312,7 @@ scuttle_land(struct lndstr *lp) getsect(lp->lnd_x, lp->lnd_y, §); snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_land == lp->lnd_uid) { @@ -330,11 +330,11 @@ scuttle_land(struct lndstr *lp) plane.pln_uid, lp->lnd_uid, xyas(plane.pln_x, plane.pln_y, plane.pln_own)); } - putplane(plane.pln_uid, (s_char *)&plane); + putplane(plane.pln_uid, &plane); } } snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_land == lp->lnd_uid) { @@ -344,7 +344,7 @@ scuttle_land(struct lndstr *lp) "Land unit %d transferred off unit %d to %s\n", land.lnd_uid, lp->lnd_uid, xyas(land.lnd_x, land.lnd_y, land.lnd_own)); - putland(land.lnd_uid, (s_char *)&land); + putland(land.lnd_uid, &land); } else scuttle_land(&land); } diff --git a/src/lib/commands/sdump.c b/src/lib/commands/sdump.c index ca78637f1..56ac3647e 100644 --- a/src/lib/commands/sdump.c +++ b/src/lib/commands/sdump.c @@ -264,7 +264,7 @@ sdump(void) nships = 0; np = getnatp(player->cnum); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { diff --git a/src/lib/commands/sect.c b/src/lib/commands/sect.c index a128fbde5..f0eef5144 100644 --- a/src/lib/commands/sect.c +++ b/src/lib/commands/sect.c @@ -80,15 +80,14 @@ sct(void) } else if (!snxtsct(&ns, str)) return RET_SYN; if (!mapbuf) - mapbuf = - (s_char *)malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + mapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); if (!map) { - map = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + map = malloc(WORLD_Y * sizeof(s_char *)); if (map && mapbuf) { for (i = 0; i < WORLD_Y; i++) map[i] = &mapbuf[MAPWIDTH(1) * i]; } else if (map) { - free((s_char *)map); + free(map); map = (s_char **)0; } } diff --git a/src/lib/commands/set.c b/src/lib/commands/set.c index f49b75b6f..39b03de69 100644 --- a/src/lib/commands/set.c +++ b/src/lib/commands/set.c @@ -90,7 +90,7 @@ set(void) type = EF_LAND; if (!snxtitem(&ni, type, player->argp[2])) return RET_SYN; - while (nxtitem(&ni, (char *)&item)) { + while (nxtitem(&ni, &item)) { if (!player->owner && !player->god) continue; getsect(item.gen.trg_x, item.gen.trg_y, §); @@ -113,7 +113,7 @@ set(void) foundslot = -1; freeslot = -1; snxtitem_all(&ni_trade, EF_TRADE); - while (nxtitem(&ni_trade, (char *)&trade)) { + while (nxtitem(&ni_trade, &trade)) { if (trade.trd_owner == 0) freeslot = ni_trade.cur; if (trade.trd_unitid == ni.cur && trade.trd_type == type) { diff --git a/src/lib/commands/shi.c b/src/lib/commands/shi.c index 7a447cc81..1188cbab2 100644 --- a/src/lib/commands/shi.c +++ b/src/lib/commands/shi.c @@ -52,7 +52,7 @@ shi(void) return RET_SYN; nships = 0; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { diff --git a/src/lib/commands/shoo.c b/src/lib/commands/shoo.c index 1cee79eab..03411d8c2 100644 --- a/src/lib/commands/shoo.c +++ b/src/lib/commands/shoo.c @@ -80,7 +80,7 @@ shoo(void) mil = sect.sct_item[I_MILIT]; nsec = 0; snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { mil += total_mil(&land); if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) { diff --git a/src/lib/commands/skyw.c b/src/lib/commands/skyw.c index 3103d50e3..af58cb37c 100644 --- a/src/lib/commands/skyw.c +++ b/src/lib/commands/skyw.c @@ -74,9 +74,9 @@ skyw(void) return RET_SYN; for (i = 0; i < TSIZE; i++) list[i] = 0; - skyp = (struct sky *)malloc(sizeof(*skyp)); + skyp = malloc(sizeof(*skyp)); snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&skyp->s_sat)) { + while (nxtitem(&ni, &skyp->s_sat)) { if (!skyp->s_sat.pln_own) continue; if (!(skyp->s_sat.pln_flags & PLN_LAUNCHED)) @@ -86,11 +86,11 @@ skyw(void) skyp->s_spotted = 0; skyp->s_next = list[n]; list[n] = skyp; - skyp = (struct sky *)malloc(sizeof(*skyp)); + skyp = malloc(sizeof(*skyp)); nsat++; } /* get that last one! */ - free((s_char *)skyp); + free(skyp); pr("- = [ Skywatch report for %s ] = -\n", cname(player->cnum)); pr(" %18s%20s %s\n", "Country", "Satellite", "Location"); tech = tfact(player->cnum, 1.0); @@ -126,7 +126,7 @@ skyw(void) for (i = 0; i < TSIZE; i++) { while (NULL != (skyp = list[i])) { list[i] = skyp->s_next; - free((s_char *)skyp); + free(skyp); } } return RET_OK; @@ -148,7 +148,7 @@ showsat(struct sky **skypp, int x, int y) do { /* we delete it, we free it. */ if (todelete) { - free((s_char *)todelete); + free(todelete); todelete = 0; } if (skyp->s_sat.pln_x != x || skyp->s_sat.pln_y != y) { @@ -170,6 +170,6 @@ showsat(struct sky **skypp, int x, int y) } while (NULL != (skyp = skyp->s_next)); /* check that last one! */ if (todelete) - free((s_char *)todelete); + free(todelete); return (nsat); } diff --git a/src/lib/commands/sona.c b/src/lib/commands/sona.c index 11d09b73a..ff006850e 100644 --- a/src/lib/commands/sona.c +++ b/src/lib/commands/sona.c @@ -80,30 +80,28 @@ sona(void) if (!snxtitem(&ni, EF_SHIP, player->argp[1])) return RET_SYN; if (!radbuf) - radbuf = - (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); + radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); if (!visbuf) - visbuf = - (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); + visbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); if (!rad) { - rad = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + rad = malloc(WORLD_Y * sizeof(s_char *)); if (rad && radbuf) { for (x = 0; x < WORLD_Y; x++) { rad[x] = &radbuf[(WORLD_X + 1) * x]; } } else if (rad) { - free((s_char *)rad); + free(rad); rad = (s_char **)0; } } if (!vis) { - vis = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + vis = malloc(WORLD_Y * sizeof(s_char *)); if (vis && visbuf) { for (x = 0; x < WORLD_Y; x++) { vis[x] = &visbuf[(WORLD_X + 1) * x]; } } else if (vis) { - free((s_char *)vis); + free(vis); vis = (s_char **)0; } } @@ -112,7 +110,7 @@ sona(void) logerror("malloc failed in sona\n"); return RET_FAIL; } - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner) continue; mcp = &mchr[(int)ship.shp_type]; diff --git a/src/lib/commands/spy.c b/src/lib/commands/spy.c index d6eecbfbf..3259c2cad 100644 --- a/src/lib/commands/spy.c +++ b/src/lib/commands/spy.c @@ -99,7 +99,7 @@ spy(void) * set up all the goodies we need later * 6 = neighbors, 2 = x,y */ - table = (coord *)malloc((nsects + 1) * 6 * 2 * sizeof(coord)); + table = malloc((nsects + 1) * 6 * 2 * sizeof(coord)); memset(table, 0, (nsects + 1) * 6 * 2 * sizeof(coord)); pr("SPY report\n"); prdate(); @@ -111,7 +111,7 @@ spy(void) nrecon = 0; nunits = 0; snxtitem_xy(&ni, EF_LAND, from.sct_x, from.sct_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { nunits++; if (lchr[(int)land.lnd_type].l_flags & L_RECON) nrecon++; @@ -208,7 +208,7 @@ spy(void) if (changed) writemap(player->cnum); player->btused += btucost; - free((s_char *)table); + free(table); return RET_OK; } @@ -275,7 +275,7 @@ num_units(int x, int y) int n = 0; snxtitem_xy(&ni, EF_LAND, x, y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if ((land.lnd_own == player->cnum) || (land.lnd_own == 0)) continue; if (land.lnd_ship >= 0 || land.lnd_land >= 0) @@ -294,7 +294,7 @@ prunits(int x, int y) s_char report[128]; snxtitem_xy(&ni, EF_LAND, x, y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == player->cnum || land.lnd_own == 0) continue; if (land.lnd_ship >= 0 || land.lnd_land >= 0) @@ -330,7 +330,7 @@ prplanes(int x, int y) s_char report[128]; snxtitem_xy(&ni, EF_PLANE, x, y); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == player->cnum || plane.pln_own == 0) continue; if (plane.pln_ship >= 0 || plane.pln_land >= 0) diff --git a/src/lib/commands/sstat.c b/src/lib/commands/sstat.c index 730a33350..48343ab69 100644 --- a/src/lib/commands/sstat.c +++ b/src/lib/commands/sstat.c @@ -49,7 +49,7 @@ sstat(void) return RET_SYN; nships = 0; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; if (ship.shp_type < 0 || ship.shp_type > shp_maxno) { diff --git a/src/lib/commands/stre.c b/src/lib/commands/stre.c index 919d1f0c7..39f436a7b 100644 --- a/src/lib/commands/stre.c +++ b/src/lib/commands/stre.c @@ -126,7 +126,7 @@ units_in_sector(struct combat *def) struct lndstr land; snxtitem_xy(&ni, EF_LAND, def->x, def->y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_own != def->own) diff --git a/src/lib/commands/strv.c b/src/lib/commands/strv.c index e7522330e..ad381d9c5 100644 --- a/src/lib/commands/strv.c +++ b/src/lib/commands/strv.c @@ -166,7 +166,7 @@ starv_ships(s_char *range) if (!snxtitem(&ni, EF_SHIP, range)) return; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (!player->owner || !ship.shp_own) continue; @@ -214,7 +214,7 @@ starv_units(s_char *range) if (!snxtitem(&ni, EF_LAND, range)) return; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner || !land.lnd_own) continue; diff --git a/src/lib/commands/supp.c b/src/lib/commands/supp.c index 9af50a83d..a22daf2f8 100644 --- a/src/lib/commands/supp.c +++ b/src/lib/commands/supp.c @@ -49,7 +49,7 @@ supp(void) return RET_SYN; nunits = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; nunits++; diff --git a/src/lib/commands/surv.c b/src/lib/commands/surv.c index ab7450821..8a401e2d5 100644 --- a/src/lib/commands/surv.c +++ b/src/lib/commands/surv.c @@ -106,7 +106,7 @@ surv(void) for (i = 0; i < WORLD_Y; i++) map[i] = &mapbuf[MAPWIDTH(1) * i]; } else if (map) { - free((s_char *)map); + free(map); map = (s_char **)0; } } diff --git a/src/lib/commands/tend.c b/src/lib/commands/tend.c index 5223a30a6..29648c97d 100644 --- a/src/lib/commands/tend.c +++ b/src/lib/commands/tend.c @@ -90,7 +90,7 @@ tend(void) getstarg(player->argp[2], "Tender(s)? ", buf))) return RET_SYN; - while (nxtitem(&tenders, (s_char *)&tender)) { + while (nxtitem(&tenders, &tender)) { if (!player->owner) continue; if (type == EF_LAND) { @@ -211,7 +211,7 @@ tend_land(struct shpstr *tenderp, s_char *units) if (!snxtitem(&lni, EF_LAND, units)) return RET_SYN; - while (nxtitem(&lni, (s_char *)&land)) { + while (nxtitem(&lni, &land)) { if (!player->owner) continue; if (land.lnd_ship != tenderp->shp_uid) { @@ -272,7 +272,7 @@ tend_land(struct shpstr *tenderp, s_char *units) count_units(tenderp); putship(tenderp->shp_uid, tenderp); snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y); - while (nxtitem(&pni, (s_char *)&plane)) { + while (nxtitem(&pni, &plane)) { if (plane.pln_flags & PLN_LAUNCHED) continue; if (plane.pln_land != land.lnd_uid) diff --git a/src/lib/commands/torp.c b/src/lib/commands/torp.c index dd6345cca..0bae564e4 100644 --- a/src/lib/commands/torp.c +++ b/src/lib/commands/torp.c @@ -81,7 +81,7 @@ torp(void) return RET_SYN; if (!snxtitem(&nbst, EF_SHIP, sav)) return RET_SYN; - while (nxtitem(&nbst, (s_char *)&sub)) { + while (nxtitem(&nbst, &sub)) { if (sub.shp_own != player->cnum) continue; if ((mchr[(int)sub.shp_type].m_flags & M_TORP) == 0) @@ -102,7 +102,7 @@ torp(void) } pr("%d ships are eligible to torp\n", ntorping); snxtitem(&nbst, EF_SHIP, sav); - while (nxtitem(&nbst, (s_char *)&sub)) { + while (nxtitem(&nbst, &sub)) { if (!sub.shp_own) continue; if (sub.shp_own != player->cnum) { diff --git a/src/lib/commands/trad.c b/src/lib/commands/trad.c index b1e2facf5..403b15395 100644 --- a/src/lib/commands/trad.c +++ b/src/lib/commands/trad.c @@ -95,7 +95,7 @@ trad(void) pr(" --- -------- -- --------- ----- -------------------------\n"); snxtitem_all(&ni, EF_TRADE); - while (nxtitem(&ni, (char *)&trade)) { + while (nxtitem(&ni, &trade)) { if (trade.trd_owner == 0) continue; if (!trade_getitem(&trade, &tg)) { @@ -512,7 +512,7 @@ check_trade(void) tg.lnd.lnd_mission = 0; /* Drop any land units this unit was carrying */ snxtitem_xy(&ni, EF_LAND, tg.lnd.lnd_x, tg.lnd.lnd_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_land != tg.lnd.lnd_uid) continue; land.lnd_land = -1; @@ -523,7 +523,7 @@ check_trade(void) } /* Drop any planes this unit was carrying */ snxtitem_xy(&ni, EF_PLANE, tg.lnd.lnd_x, tg.lnd.lnd_y); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_flags & PLN_LAUNCHED) continue; if (plane.pln_land != land.lnd_uid) @@ -541,7 +541,7 @@ check_trade(void) logerror("Bad trade type %d in trade\n", trade.trd_type); break; } - if (!ef_write(trade.trd_type, saveid, (char *)&tg)) { + if (!ef_write(trade.trd_type, saveid, &tg)) { logerror("Couldn't write unit to disk; seek help.\n"); continue; } diff --git a/src/lib/commands/tran.c b/src/lib/commands/tran.c index b24493e69..84652ac01 100644 --- a/src/lib/commands/tran.c +++ b/src/lib/commands/tran.c @@ -208,7 +208,7 @@ tran_plane(void) * No one could seriously want to move planes in parallel from * several sectors! */ - while (nxtitem(&nstr, (s_char *)&plane)) { + while (nxtitem(&nstr, &plane)) { if (!player->owner) continue; type = plane.pln_type; @@ -260,7 +260,7 @@ tran_plane(void) dstx = endsect.sct_x; dsty = endsect.sct_y; snxtitem_rewind(&nstr); - while (nxtitem(&nstr, (s_char *)&plane)) { + while (nxtitem(&nstr, &plane)) { if (!player->owner) continue; if (dam) diff --git a/src/lib/commands/trea.c b/src/lib/commands/trea.c index d05e42dcc..9984aecf6 100644 --- a/src/lib/commands/trea.c +++ b/src/lib/commands/trea.c @@ -51,7 +51,7 @@ trea(void) return RET_SYN; pr("\t... %s Treaty Report ...\n", cname(player->cnum)); ntreaty = 0; - while (nxtitem(&nstr, (s_char *)&treaty)) { + while (nxtitem(&nstr, &treaty)) { if (distrea(nstr.cur, &treaty) > 0) ntreaty++; } diff --git a/src/lib/commands/upgr.c b/src/lib/commands/upgr.c index c1ddd72ae..51acde5d0 100644 --- a/src/lib/commands/upgr.c +++ b/src/lib/commands/upgr.c @@ -98,7 +98,7 @@ lupgr(void) cash = natp->nat_money; tlev = (int)natp->nat_level[NAT_TLEV]; n = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; getsect(land.lnd_x, land.lnd_y, §); @@ -181,7 +181,7 @@ supgr(void) cash = natp->nat_money; tlev = (int)natp->nat_level[NAT_TLEV]; n = 0; - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (ship.shp_own == 0) continue; getsect(ship.shp_x, ship.shp_y, §); @@ -263,7 +263,7 @@ pupgr(void) cash = natp->nat_money; tlev = (int)natp->nat_level[NAT_TLEV]; n = 0; - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; getsect(plane.pln_x, plane.pln_y, §); diff --git a/src/lib/commands/work.c b/src/lib/commands/work.c index 1e33a769c..0fa4d57b5 100644 --- a/src/lib/commands/work.c +++ b/src/lib/commands/work.c @@ -67,7 +67,7 @@ work(void) return RET_FAIL; } nunits = 0; - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) { diff --git a/src/lib/common/bestpath.c b/src/lib/common/bestpath.c index 327e6ef0d..aa8408840 100644 --- a/src/lib/common/bestpath.c +++ b/src/lib/common/bestpath.c @@ -132,13 +132,12 @@ bestownedpath(s_char *bpath, unsigned int routelen; if (!mapbuf) - mapbuf = (unsigned int *)malloc((WORLD_X * WORLD_Y) * + mapbuf = malloc((WORLD_X * WORLD_Y) * sizeof(unsigned int)); if (!mapbuf) return ((s_char *)0); if (!mapindex) { - mapindex = - (unsigned int **)malloc(WORLD_X * sizeof(unsigned int *)); + mapindex = malloc(WORLD_X * sizeof(unsigned int *)); if (mapindex) { /* Setup the map pointers */ for (i = 0; i < WORLD_X; i++) @@ -160,7 +159,7 @@ bestownedpath(s_char *bpath, if (x == ex && y == ey) { bpath[0] = 'h'; bpath[1] = 0; - return ((s_char *)bpath); + return bpath; } if (!valid(x, y) || !valid(ex, ey)) @@ -186,7 +185,7 @@ bestownedpath(s_char *bpath, if (++routelen == MAXROUTE) { bpath[0] = '?'; bpath[1] = 0; - return ((s_char *)bpath); + return bpath; } markedsectors = 0; for (scanx = minx; scanx <= maxx; scanx++) { @@ -219,7 +218,7 @@ bestownedpath(s_char *bpath, tx = XNORM(tx); ty = YNORM(ty); } - return ((s_char *)bpath); + return bpath; } } } diff --git a/src/lib/common/bridgefall.c b/src/lib/common/bridgefall.c index 6a6276761..a90255750 100644 --- a/src/lib/common/bridgefall.c +++ b/src/lib/common/bridgefall.c @@ -117,7 +117,7 @@ knockdown(struct sctstr *sp, struct emp_qelem *list) /* Sink all the units */ snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_x != sp->sct_x || land.lnd_y != sp->sct_y) @@ -137,7 +137,7 @@ knockdown(struct sctstr *sp, struct emp_qelem *list) } /* Sink all the planes */ snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_x != sp->sct_x || plane.pln_y != sp->sct_y) diff --git a/src/lib/common/land.c b/src/lib/common/land.c index b9ccdc6d8..0f5156abb 100644 --- a/src/lib/common/land.c +++ b/src/lib/common/land.c @@ -62,7 +62,7 @@ has_units(coord x, coord y, natid cn, struct lndstr *lp) int n; struct lndstr land; - for (n = 0; ef_read(EF_LAND, n, (s_char *)&land); n++) { + for (n = 0; ef_read(EF_LAND, n, &land); n++) { if (land.lnd_x != x || land.lnd_y != y) continue; if (lp) { @@ -85,7 +85,7 @@ has_units_with_mob(coord x, coord y, natid cn) struct lndstr land; snxtitem_xy(&ni, EF_LAND, x, y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own != cn) continue; if (land.lnd_mobil > 0) @@ -105,7 +105,7 @@ has_helpful_engineer(coord x, coord y, natid cn) struct lndstr land; snxtitem_xy(&ni, EF_LAND, x, y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own != cn && getrel(getnatp(land.lnd_own), cn) != ALLIED) continue; if (lchr[(int)land.lnd_type].l_flags & L_ENGINEER) diff --git a/src/lib/common/maps.c b/src/lib/common/maps.c index 3ae28c277..dd1b2a4b5 100644 --- a/src/lib/common/maps.c +++ b/src/lib/common/maps.c @@ -70,20 +70,19 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp, static s_char **wmap = (s_char **)0; if (!wmapbuf) - wmapbuf = - (s_char *)malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); + wmapbuf = malloc((WORLD_Y * MAPWIDTH(1)) * sizeof(s_char)); if (!wmap) { - wmap = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + wmap = malloc(WORLD_Y * sizeof(s_char *)); if (wmap && wmapbuf) { for (i = 0; i < WORLD_Y; i++) wmap[i] = &wmapbuf[MAPWIDTH(1) * i]; } else if (wmap) { - free((s_char *)wmap); + free(wmap); wmap = (s_char **)0; } } if (!bitmap) - bitmap = (u_char *)malloc((WORLD_X * WORLD_Y) / 8); + bitmap = malloc((WORLD_X * WORLD_Y) / 8); if (!wmapbuf || !wmap || !bitmap) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in draw_map\n"); diff --git a/src/lib/common/path.c b/src/lib/common/path.c index 99b667a52..3122e426e 100644 --- a/src/lib/common/path.c +++ b/src/lib/common/path.c @@ -81,7 +81,7 @@ bp_init(void) ep = &empfile[EF_SECTOR]; - bp = (struct bestp *)malloc(sizeof(*bp)); + bp = malloc(sizeof(*bp)); memset(bp, 0, sizeof(*bp)); bp->adp = as_init(BP_NEIGHBORS, BP_ASHASHSIZE, bp_coord_hash, bp_neighbors, bp_lbcost, bp_realcost, @@ -91,9 +91,8 @@ bp_init(void) return NULL; if (neighsects == (struct sctstr **)0) - neighsects = (struct sctstr **)calloc(1, (sizeof(struct sctstr *) * - ((WORLD_X * WORLD_Y) / - 2) * 6)); + neighsects = calloc(((WORLD_X * WORLD_Y) / 2) * 6, + sizeof(struct sctstr *)); return (s_char *)bp; } diff --git a/src/lib/common/sectdamage.c b/src/lib/common/sectdamage.c index a16e21a34..47208eabb 100644 --- a/src/lib/common/sectdamage.c +++ b/src/lib/common/sectdamage.c @@ -108,7 +108,7 @@ sectdamage(struct sctstr *sp, int dam, struct emp_qelem *list) return eff; snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!land.lnd_own) continue; landdamage(&land, dam); @@ -119,7 +119,7 @@ sectdamage(struct sctstr *sp, int dam, struct emp_qelem *list) if (dam <= 0) return eff; snxtitem_xy(&ni, EF_PLANE, sp->sct_x, sp->sct_y); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (!plane.pln_own) continue; if (plane.pln_flags & PLN_LAUNCHED) diff --git a/src/lib/empthread/ntthread.c b/src/lib/empthread/ntthread.c index 8412bbfd3..5d87ed73e 100644 --- a/src/lib/empthread/ntthread.c +++ b/src/lib/empthread/ntthread.c @@ -414,7 +414,7 @@ empth_init(char **ctx_ptr, int flags) SetConsoleCtrlHandler((PHANDLER_ROUTINE)loc_Exit_Handler, TRUE); /* Create the global Thread context. */ - pThread = (loc_Thread_t *)malloc(sizeof(*pThread)); + pThread = malloc(sizeof(*pThread)); if (!pThread) { logerror("not enough memory to create main thread."); return 0; @@ -461,7 +461,7 @@ empth_create(int prio, void (*entry)(void *), int size, int flags, loc_debug("creating new thread %s:%s", name, desc); - pThread = (loc_Thread_t *)malloc(sizeof(*pThread)); + pThread = malloc(sizeof(*pThread)); if (!pThread) { logerror("not enough memory to create thread: %s (%s)", name, desc); @@ -671,7 +671,7 @@ empth_sem_create(char *name, int cnt) { loc_Sem_t *pSem; - pSem = (loc_Sem_t *)malloc(sizeof(*pSem)); + pSem = malloc(sizeof(*pSem)); if (!pSem) { logerror("out of memory at %s:%d", __FILE__, __LINE__); return NULL; diff --git a/src/lib/empthread/pthread.c b/src/lib/empthread/pthread.c index 41cee7b7d..6379d5b08 100644 --- a/src/lib/empthread/pthread.c +++ b/src/lib/empthread/pthread.c @@ -140,7 +140,7 @@ empth_init(char **ctx_ptr, int flags) sigaction(SIGALRM, &act, NULL); udata = ctx_ptr; - ctx = (empth_t *)malloc(sizeof(empth_t)); + ctx = malloc(sizeof(empth_t)); if (!ctx) { logerror("pthread init failed: not enough memory"); exit(1); @@ -176,7 +176,7 @@ empth_create(int prio, void (*entry)(void *), int size, int flags, empth_status("creating new thread %s:%s", name, desc); - ctx = (empth_t *)malloc(sizeof(empth_t)); + ctx = malloc(sizeof(empth_t)); if (!ctx) { logerror("not enough memoty to create thread: %s (%s)", name, desc); @@ -262,7 +262,7 @@ empth_restorectx(void) #else ctx_ptr = (empth_t *)pthread_getspecific(ctx_key); #endif - *udata = (char *)ctx_ptr->ud; + *udata = ctx_ptr->ud; if (ctx_ptr->state == EMPTH_KILLED) { empth_status("i am dead"); empth_exit(); @@ -447,7 +447,7 @@ empth_sem_create(char *name, int cnt) { empth_sem_t *sm; - sm = (empth_sem_t *)malloc(sizeof(empth_sem_t)); + sm = malloc(sizeof(empth_sem_t)); if (!sm) { logerror("out of memory at %s:%d", __FILE__, __LINE__); return NULL; diff --git a/src/lib/gen/io.c b/src/lib/gen/io.c index 983eccb1f..f7efadc71 100644 --- a/src/lib/gen/io.c +++ b/src/lib/gen/io.c @@ -89,7 +89,7 @@ io_open(int fd, int flags, int bufsize, int (*notify)(void), flags = flags & (IO_READ | IO_WRITE | IO_NBLOCK | IO_NEWSOCK); if ((flags & (IO_READ | IO_WRITE)) == 0) return NULL; - iop = (struct iop *)malloc(sizeof(struct iop)); + iop = malloc(sizeof(struct iop)); if (!iop) return NULL; iop->fd = fd; @@ -122,7 +122,7 @@ io_close(struct iop *iop) #else closesocket(iop->fd); #endif - free((s_char *)iop); + free(iop); } int diff --git a/src/lib/gen/ioqueue.c b/src/lib/gen/ioqueue.c index 472a85563..16ab4fd3e 100644 --- a/src/lib/gen/ioqueue.c +++ b/src/lib/gen/ioqueue.c @@ -66,7 +66,7 @@ ioq_create(int size) { struct ioqueue *ioq; - ioq = (struct ioqueue *)malloc(sizeof(struct ioqueue)); + ioq = malloc(sizeof(struct ioqueue)); emp_initque(&ioq->list.queue); ioq->list.nbytes = 0; ioq->list.offset = 0; @@ -84,7 +84,7 @@ ioq_destroy(struct ioqueue *ioq) /* ioq_drain doesn't work under aix or NeXT... dunno why --ts */ ioq_drain(ioq); #endif /* aix */ - free((s_char *)ioq); + free(ioq); } void @@ -318,7 +318,7 @@ appendcc(struct ioqueue *ioq, s_char *buf, int cc) len = cc > ioq->bufsize ? cc : ioq->bufsize; ptr = malloc(len); memcpy(ptr, buf, cc); - io = (struct io *)malloc(sizeof(struct io)); + io = malloc(sizeof(struct io)); io->nbytes = cc; io->size = len; io->offset = 0; diff --git a/src/lib/gen/strdup.c b/src/lib/gen/strdup.c index a9ee4d50f..05c8e755c 100644 --- a/src/lib/gen/strdup.c +++ b/src/lib/gen/strdup.c @@ -41,7 +41,7 @@ strdup(char *x) { char *y; - y = (char *)malloc((sizeof(char) * strlen(x)) + 1); + y = malloc((sizeof(char) * strlen(x)) + 1); strcpy(y, x); return y; } diff --git a/src/lib/lwp/arch.c b/src/lib/lwp/arch.c index da05e4f9a..75282412f 100644 --- a/src/lib/lwp/arch.c +++ b/src/lib/lwp/arch.c @@ -71,7 +71,7 @@ lwpInitContext(struct lwpProc *newp, void *sp) int endpoint; if (initcontext == NULL) { - initcontext = (struct lwpProc *)malloc(sizeof(struct lwpProc)); + initcontext = malloc(sizeof(struct lwpProc)); tempcontext = &holder; if (!setjmp(tempcontext->context)) startcontext(); diff --git a/src/lib/lwp/lwp.c b/src/lib/lwp/lwp.c index 464dbdd30..6d7e0e901 100644 --- a/src/lib/lwp/lwp.c +++ b/src/lib/lwp/lwp.c @@ -215,7 +215,7 @@ lwpCreate(int priority, void (*entry)(void *), int size, int flags, char *name, #endif /* UCONTEXT */ unsigned long stackp; - if (!(newp = (struct lwpProc *)malloc(sizeof(struct lwpProc)))) + if (!(newp = malloc(sizeof(struct lwpProc)))) return (0); if (flags & LWP_STACKCHECK) { /* Add a 1K buffer on each side of the stack */ @@ -223,7 +223,7 @@ lwpCreate(int priority, void (*entry)(void *), int size, int flags, char *name, } size += LWP_EXTRASTACK; size += sizeof(stkalign_t); - if (!(s = (int *)malloc(size))) + if (!(s = malloc(size))) return (0); newp->flags = flags; newp->name = strdup(name); @@ -304,7 +304,7 @@ lwpDestroy(struct lwpProc *proc) proc->entry = 0; proc->ud = 0; proc->argv = 0; - free((char *)proc->sbtm); + free(proc->sbtm); free(proc->name); free(proc->desc); proc->name = 0; @@ -312,7 +312,7 @@ lwpDestroy(struct lwpProc *proc) proc->sbtm = 0; proc->lowmark = 0; proc->himark = 0; - free((char *)proc); + free(proc); } /* @@ -434,7 +434,7 @@ lwpInitSystem(int pri, char **ctxptr, int flags) /* *LwpContextPtr = 0; */ if (!(LwpCurrent = calloc(1, sizeof(struct lwpProc)))) return (0); - if (!(stack = (int *)malloc(64))) + if (!(stack = malloc(64))) return (0); if (LWP_MAX_PRIO <= pri) pri = LWP_MAX_PRIO - 1; diff --git a/src/lib/lwp/sel.c b/src/lib/lwp/sel.c index 9e2aaaca8..419153d5d 100644 --- a/src/lib/lwp/sel.c +++ b/src/lib/lwp/sel.c @@ -73,8 +73,7 @@ lwpInitSelect(struct lwpProc *proc) #endif FD_ZERO(&LwpSelect.readmask); FD_ZERO(&LwpSelect.writemask); - LwpSelect.wait = (struct lwpProc **) - calloc(LwpSelect.nfile, sizeof(char *)); + LwpSelect.wait = calloc(LwpSelect.nfile, sizeof(char *)); LwpSelect.delayq.head = 0; LwpSelect.delayq.tail = 0; LwpSelect.proc = proc; diff --git a/src/lib/lwp/sem.c b/src/lib/lwp/sem.c index b6bd8df4c..055722214 100644 --- a/src/lib/lwp/sem.c +++ b/src/lib/lwp/sem.c @@ -42,7 +42,7 @@ lwpCreateSem(char *name, int count) { struct lwpSem *new; - if (!(new = (struct lwpSem *)malloc(sizeof(struct lwpSem)))) + if (!(new = malloc(sizeof(struct lwpSem)))) return (0); new->name = strdup(name); new->count = count; diff --git a/src/lib/player/accept.c b/src/lib/player/accept.c index 0bba56275..55b354be6 100644 --- a/src/lib/player/accept.c +++ b/src/lib/player/accept.c @@ -93,8 +93,7 @@ player_init(void) } val = 1; #if !(defined(__linux__) && defined(__alpha__)) - if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)) - < 0) { + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val)) < 0) { logerror("inet socket setsockopt SO_REUSEADDR (%d)", errno); exit(1); } @@ -128,7 +127,7 @@ player_new(int s, struct sockaddr_in *sin) struct hostent *hostp; #endif - lp = (struct player *)malloc(sizeof(struct player)); + lp = malloc(sizeof(struct player)); if (!lp) return NULL; memset(lp, 0, sizeof(struct player)); @@ -145,9 +144,8 @@ player_new(int s, struct sockaddr_in *sin) strcpy(lp->hostaddr, inet_ntoa(sin->sin_addr)); #ifdef RESOLVE_IPADDRESS if (NULL != - (hostp = - gethostbyaddr((char *)&sin->sin_addr, sizeof(sin->sin_addr), - AF_INET))) + (hostp = gethostbyaddr(&sin->sin_addr, sizeof(sin->sin_addr), + AF_INET))) strcpy(lp->hostname, hostp->h_name); #endif /* RESOLVE_IPADDRESS */ lp->cnum = 255; @@ -170,7 +168,7 @@ player_delete(struct player *lp) io_close(lp->iop); lp->iop = 0; } - free((s_char *)lp); + free(lp); /* XXX may need to free bigmap here */ return back; } @@ -263,8 +261,7 @@ player_accept(void *unused) logerror("new socket accept"); continue; } - (void)setsockopt(ns, SOL_SOCKET, SO_KEEPALIVE, - (char *)&set, sizeof(set)); + (void)setsockopt(ns, SOL_SOCKET, SO_KEEPALIVE, &set, sizeof(set)); np = player_new(ns, &sin); if (!np) { logerror("can't create player for fd %d", ns); diff --git a/src/lib/player/login.c b/src/lib/player/login.c index a016ef6c7..015352cd8 100644 --- a/src/lib/player/login.c +++ b/src/lib/player/login.c @@ -152,7 +152,7 @@ sanc_cmd(void) } snxtitem_all(&ni, EF_NATION); - while (nxtitem(&ni, (s_char *)&nat)) { + while (nxtitem(&ni, &nat)) { if (nat.nat_stat != (STAT_INUSE | STAT_SANCT)) continue; if (first) { diff --git a/src/lib/subs/aircombat.c b/src/lib/subs/aircombat.c index e61891a0e..6ea14bfb4 100644 --- a/src/lib/subs/aircombat.c +++ b/src/lib/subs/aircombat.c @@ -269,7 +269,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, /* Go figure out if there are ships in this sector, and who's they are */ memset(nats, 0, sizeof(nats)); snxtitem_xy(&ni, EF_SHIP, x, y); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (mchr[(int)ship.shp_type].m_flags & M_SUB) continue; nats[ship.shp_own]++; @@ -277,7 +277,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, /* Go figure out if there are units in this sector, and who's they are */ memset(lnats, 0, sizeof(lnats)); snxtitem_xy(&ni, EF_LAND, x, y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_ship >= 0 || land.lnd_land >= 0) continue; lnats[land.lnd_own]++; @@ -390,12 +390,12 @@ sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list, if (dplp->plane.pln_range < mapdist(x, y, dplp->plane.pln_x, dplp->plane.pln_y)) { emp_remque(dqp); - free((s_char *)dqp); + free(dqp); continue; } if (mission_pln_equip(dplp, 0, P_F, 0) < 0) { emp_remque(dqp); - free((s_char *)dqp); + free(dqp); continue; } if (first) { @@ -421,7 +421,7 @@ sam_intercept(struct emp_qelem *att_list, struct emp_qelem *def_list, if (!(dplp->pcp->pl_flags & P_M)) continue; emp_remque(dqp); - free((s_char *)dqp); + free(dqp); continue; } } @@ -465,7 +465,7 @@ ac_intercept(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, continue; if (mission_pln_equip(plp, 0, P_F, 0) < 0) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } /* got one; delete from def_list, add to int_list */ @@ -746,11 +746,11 @@ ac_planedamage(struct plist *plp, natid from, int dam, natid other, pp->pln_own = 0; putplane(pp->pln_uid, pp); emp_remque(&plp->queue); - free((s_char *)plp); + free(plp); } else if (disp == 2) { putplane(pp->pln_uid, pp); emp_remque(&plp->queue); - free((s_char *)plp); + free(plp); } else putplane(pp->pln_uid, pp); strcpy(mesg, dmess); @@ -813,7 +813,7 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y) memset(nats, 0, sizeof(nats)); guns = 0; snxtitem_xy(&ni, EF_SHIP, x, y); - while (!QEMPTY(list) && nxtitem(&ni, (s_char *)&ship)) { + while (!QEMPTY(list) && nxtitem(&ni, &ship)) { if (ship.shp_own == 0 || ship.shp_own == plane_owner) continue; if (guns >= 14) @@ -881,7 +881,7 @@ ac_landflak(struct emp_qelem *list, coord x, coord y) memset(nats, 0, sizeof(nats)); guns = 0; snxtitem_xy(&ni, EF_LAND, x, y); - while (!QEMPTY(list) && nxtitem(&ni, (s_char *)&land)) { + while (!QEMPTY(list) && nxtitem(&ni, &land)) { if (land.lnd_own == 0 || land.lnd_own == plane_owner) continue; if (guns >= 14) @@ -1034,7 +1034,7 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a, emp_initque(list); snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own != own) continue; pcp = &plchr[(int)plane.pln_type]; @@ -1076,7 +1076,7 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a, if (ac_isflying(&plane, d)) continue; /* got one! */ - ip = (struct plist *)malloc(sizeof(*ip)); + ip = malloc(sizeof(*ip)); ip->state = P_OK; ip->bombs = 0; ip->misc = 0; diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index f69581e09..040b2423f 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -1020,7 +1020,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def, maxland = def->shp_mcp->m_nland; snxtitem_xy(&ni, EF_LAND, off->x, off->y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own != player->cnum) continue; if (land.lnd_effic < LAND_MINEFF) @@ -1111,7 +1111,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def, land_answer[(int)land.lnd_army] != 'Y') continue; } - if (!(llp = (struct llist *)malloc(sizeof(struct llist)))) { + if (!(llp = malloc(sizeof(struct llist)))) { logerror("Malloc failed in attack!\n"); abort_attack(); return; @@ -1257,7 +1257,7 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy, lists. Spies try to hide, trains get trapped and can be boarded. */ snxtitem_xy(&ni, EF_LAND, def->x, def->y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!land.lnd_own) continue; if (land.lnd_own != def->own) @@ -1276,7 +1276,7 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy, "Scouts report defending unit:"); continue; } - if (!(llp = (struct llist *)malloc(sizeof(struct llist)))) { + if (!(llp = malloc(sizeof(struct llist)))) { logerror("Malloc failed in attack!\n"); abort_attack(); return 0; @@ -1498,7 +1498,7 @@ put_land(struct emp_qelem *list) putland(llp->land.lnd_uid, &llp->land); if (llp->land.lnd_own != player->cnum) { emp_remque((struct emp_qelem *)llp); - free((s_char *)llp); + free(llp); } else get_land(A_ATTACK, 0, llp->land.lnd_uid, llp, 0); } @@ -1543,7 +1543,7 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy, else dtotal = 0; snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land) && + while (nxtitem(&ni, &land) && (dtotal + new_land * eff < (int)(1.2 * (float)ototal))) { if (!land.lnd_own) continue; diff --git a/src/lib/subs/control.c b/src/lib/subs/control.c index a5c66b265..ac26d4f8b 100644 --- a/src/lib/subs/control.c +++ b/src/lib/subs/control.c @@ -56,7 +56,7 @@ military_control(struct sctstr *sp) if (sp->sct_oldown != sp->sct_own) { snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == sp->sct_own) tot_mil += total_mil(&land); } diff --git a/src/lib/subs/list.c b/src/lib/subs/list.c index 5963763cc..da37fde49 100644 --- a/src/lib/subs/list.c +++ b/src/lib/subs/list.c @@ -54,7 +54,7 @@ shipsatxy(coord x, coord y, int wantflags, int nowantflags) first = 1; ships = 0; snxtitem_xy(&ni, EF_SHIP, x, y); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (player->owner) continue; if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) @@ -93,7 +93,7 @@ carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own) first = 1; ships = 0; snxtitem_xy(&ni, EF_SHIP, x, y); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) continue; if (ship.shp_own != own @@ -133,7 +133,7 @@ unitsatxy(coord x, coord y, int wantflags, int nowantflags) first = 1; units = 0; snxtitem_xy(&ni, EF_LAND, x, y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0) continue; /* Can't bomb units on ships or other units */ @@ -179,7 +179,7 @@ planesatxy(coord x, coord y, int wantflags, int nowantflags, planes = 0; first = 1; snxtitem_xy(&ni, EF_PLANE, x, y); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0) continue; if (plane.pln_flags & PLN_LAUNCHED) @@ -220,7 +220,7 @@ asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags, first = 1; ships = 0; snxtitem_xy(&ni, EF_SHIP, x, y); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (player->owner) continue; if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) @@ -261,7 +261,7 @@ num_shipsatxy(coord x, coord y, int wantflags, int nowantflags) ships = 0; snxtitem_xy(&ni, EF_SHIP, x, y); - while (nxtitem(&ni, (s_char *)&ship)) { + while (nxtitem(&ni, &ship)) { if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) continue; mp = &mchr[(int)ship.shp_type]; diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 979cf0fa7..8ce218cf0 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -163,7 +163,7 @@ lnd_delete(struct llist *llp, s_char *s) lnd_print(llp, s); putland(llp->land.lnd_uid, &llp->land); emp_remque((struct emp_qelem *)llp); - free((s_char *)llp); + free(llp); } int @@ -204,9 +204,8 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas) if (llp->land.lnd_effic < LAND_MINEFF) { sprintf(buf, "dies %s %s!", - combat_mode ? att_mode[combat_mode] : (s_char *) - "defending", xyas(llp->land.lnd_x, llp->land.lnd_y, - llp->land.lnd_own)); + combat_mode ? att_mode[combat_mode] : "defending", + xyas(llp->land.lnd_x, llp->land.lnd_y, llp->land.lnd_own)); lnd_delete(llp, buf); /* Since we killed the unit, we killed all the mil on it */ return taken; @@ -433,7 +432,7 @@ count_sect_units(struct sctstr *sp) struct lndstr land; snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (!land.lnd_own) continue; if (land.lnd_x != sp->sct_x || land.lnd_y != sp->sct_y) @@ -461,7 +460,7 @@ count_units(struct shpstr *sp) return; snxtitem_xy(&ni, EF_LAND, sp->shp_x, sp->shp_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_ship == sp->shp_uid) @@ -485,7 +484,7 @@ lnd_count_units(struct lndstr *lp) return; snxtitem_xy(&ni, EF_LAND, lp->lnd_x, lp->lnd_y); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_own == 0) continue; if (land.lnd_land == lp->lnd_uid) @@ -511,7 +510,7 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) struct llist *llp; emp_initque(list); - while (nxtitem(ni, (s_char *)&land)) { + while (nxtitem(ni, &land)) { if (!player->owner) continue; if (opt_MARKET) { @@ -546,7 +545,7 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) land.lnd_harden = 0; memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); putland(land.lnd_uid, &land); - llp = (struct llist *)malloc(sizeof(struct llist)); + llp = malloc(sizeof(struct llist)); llp->lcp = lcp; llp->land = land; llp->mobil = (double)land.lnd_mobil; @@ -581,7 +580,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp, mpr(actor, "%s was disbanded at %s\n", prland(&land), xyas(land.lnd_x, land.lnd_y, land.lnd_own)); emp_remque((struct emp_qelem *)llp); - free((s_char *)llp); + free(llp); continue; } if (land.lnd_ship >= 0) { @@ -648,7 +647,7 @@ lnd_put(struct emp_qelem *list, natid actor) putland(llp->land.lnd_uid, &llp->land); newqp = qp->q_back; emp_remque(qp); - free((s_char *)qp); + free(qp); qp = newqp; } } @@ -764,11 +763,11 @@ lnd_check_mines(struct emp_qelem *land_list) lnd_hit_mine(&llp->land, llp->lcp); sect.sct_mines--; putsect(§); - putland(llp->land.lnd_uid, (s_char *)&llp->land); + putland(llp->land.lnd_uid, &llp->land); if (!llp->land.lnd_own) { stopping = 1; emp_remque(qp); - free((s_char *)qp); + free(qp); } } } @@ -816,7 +815,7 @@ lnd_mess(s_char *str, struct llist *llp) llp->land.lnd_mobil = llp->mobil; putland(llp->land.lnd_uid, &llp->land); emp_remque((struct emp_qelem *)llp); - free((s_char *)llp); + free(llp); } static int @@ -856,7 +855,7 @@ lnd_damage(struct emp_qelem *list, int totdam) putland(llp->land.lnd_uid, &llp->land); if (!llp->land.lnd_own) { emp_remque(qp); - free((s_char *)qp); + free(qp); } } return dam; @@ -1254,7 +1253,7 @@ lnd_support(natid victim, natid attacker, coord x, coord y, int defending) double range, range2; snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_frg == 0) continue; if ((land.lnd_x == x) && (land.lnd_y == y)) @@ -1336,9 +1335,9 @@ lnd_path(int together, struct lndstr *lp, s_char *buf) } getsect(lp->lnd_x, lp->lnd_y, §); if (lchr[(int)lp->lnd_type].l_flags & L_TRAIN) - cp = (s_char *)BestLandPath(buf, §, &d_sect, &dummy, MOB_RAIL); + cp = BestLandPath(buf, §, &d_sect, &dummy, MOB_RAIL); else - cp = (s_char *)BestLandPath(buf, §, &d_sect, &dummy, MOB_ROAD); + cp = BestLandPath(buf, §, &d_sect, &dummy, MOB_ROAD); if (!cp) { pr("No owned path from %s to %s!\n", xyas(lp->lnd_x, lp->lnd_y, player->cnum), diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index 82cfcece9..1a86976c0 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -309,7 +309,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission, /* size = max(sizeof(struct shpstr),sizeof(struct lndstr)); size = max(size,sizeof(struct plnstr)); - block = (s_char *)malloc(size); + block = malloc(size); */ size = sizeof(u_block); block = (s_char *)&u_block; @@ -360,7 +360,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission, if (opt_SLOW_WAR) { if (mission != MI_AIR_DEFENSE) { - getsect(x, y, (s_char *)§); + getsect(x, y, §); if (getrel(getnatp(gp->own), sect.sct_own) > AT_WAR) { /* @@ -377,7 +377,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission, } } - glp = (struct genlist *)malloc(sizeof(struct genlist)); + glp = malloc(sizeof(struct genlist)); memset(glp, 0, sizeof(struct genlist)); glp->x = gp->x; glp->y = gp->y; @@ -393,7 +393,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission, glp->cp = (s_char *)&plchr[(int)gp->type]; break; } - glp->thing = (s_char *)malloc(size); + glp->thing = malloc(size); memcpy(glp->thing, block, size); emp_insque(&glp->queue, &mi[gp->own].queue); } @@ -408,7 +408,7 @@ find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts) int dist; snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own != cn) continue; @@ -420,7 +420,7 @@ find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts) if (dist > ((int)((float)plane.pln_range / 2.0))) continue; - plp = (struct plist *)malloc(sizeof(struct plist)); + plp = malloc(sizeof(struct plist)); memset(plp, 0, sizeof(struct plist)); plp->pcp = &plchr[(int)plane.pln_type]; plp->plane = plane; @@ -656,7 +656,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list, continue; /* save planes for later */ - plp = (struct plist *)malloc(sizeof(struct plist)); + plp = malloc(sizeof(struct plist)); memset(plp, 0, sizeof(struct plist)); plp->pcp = pcp; @@ -689,7 +689,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list, qp = qp->q_forw; free(glp->thing); - free((s_char *)glp); + free(glp); } return dam; } @@ -779,14 +779,14 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list, qp = qp->q_forw; free(glp->thing); - free((s_char *)glp); + free(glp); } qp = escorts.q_forw; while (qp != (&escorts)) { newqp = qp->q_forw; emp_remque(qp); - free((s_char *)qp); + free(qp); qp = newqp; } @@ -794,7 +794,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list, while (qp != (&bombers)) { newqp = qp->q_forw; emp_remque(qp); - free((s_char *)qp); + free(qp); qp = newqp; } @@ -906,7 +906,7 @@ show_mission(int type, struct nstr_item *np) size = max(sizeof(struct lndstr), sizeof(struct plnstr)); size = max(size, sizeof(struct shpstr)); - block = (s_char *)malloc(size); + block = malloc(size); while (nxtitem(np, block)) { gp = (struct genitem *)block; @@ -1018,20 +1018,20 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, if (pp->pln_effic < 40) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (pp->pln_mobil < 1) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (opt_MARKET) { if (ontradingblock(EF_PLANE, (int *)pp)) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1060,7 +1060,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, } if (bad) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (bad1 == 2) { @@ -1074,7 +1074,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, } if (bad1) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1089,7 +1089,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, } if (bad) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1099,7 +1099,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, pp->pln_effic = 0; putplane(pp->pln_uid, pp); emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (!can_be_on_ship(pp->pln_uid, ship.shp_uid)) { @@ -1113,7 +1113,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, ((ship.shp_own != pp->pln_own) && (getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED))) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1123,7 +1123,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, pp->pln_effic = 0; putplane(pp->pln_uid, pp); emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (!(pcp->pl_flags & P_E)) @@ -1136,14 +1136,14 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, ((land.lnd_own != pp->pln_own) && (getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED))) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } /* Can't fly off units in ships or other units */ if ((land.lnd_ship >= 0) || (land.lnd_land >= 0)) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1152,7 +1152,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, /* If we can't get the sector, we can't check it, and can't fly */ if (!getsect(pp->pln_x, pp->pln_y, §)) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } /* First, check allied status */ @@ -1160,14 +1160,14 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, if ((sect.sct_own != pp->pln_own) && (getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED)) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } /* non-vtol plane */ if ((pcp->pl_flags & P_V) == 0) { if ((sect.sct_type != SCT_AIRPT) || (sect.sct_effic < 40)) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1175,7 +1175,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, if (pcp->pl_flags & P_A) { if (roll(100) > pln_identchance(pp, hardtarget, EF_SHIP)) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } } @@ -1210,7 +1210,7 @@ mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist, if (mission_pln_equip(plp, ip, flags, mission) < 0) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (flags & (P_S | P_I)) { @@ -1371,7 +1371,7 @@ add_airport(struct emp_qelem *airp, coord x, coord y) struct airport *a; struct sctstr sect; - a = (struct airport *)malloc(sizeof(struct airport)); + a = malloc(sizeof(struct airport)); a->x = x; a->y = y; @@ -1554,7 +1554,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list, dist = mapdist(x, y, gp->x, gp->y); - plp = (struct plist *)malloc(sizeof(struct plist)); + plp = malloc(sizeof(struct plist)); memset(plp, 0, sizeof(struct plist)); plp->pcp = (struct plchrstr *)glp->cp; memcpy(&plp->plane, glp->thing, sizeof(struct plnstr)); @@ -1594,7 +1594,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list, /* Free it up and continue */ emp_remque(qp); glp = (struct genlist *)qp; - free((s_char *)glp); + free(glp); } } @@ -1704,7 +1704,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list, next = qp->q_forw; glp = (struct genlist *)qp; free(glp->thing); - free((s_char *)glp); + free(glp); } } diff --git a/src/lib/subs/mslsub.c b/src/lib/subs/mslsub.c index 81ff01243..9153f61d9 100644 --- a/src/lib/subs/mslsub.c +++ b/src/lib/subs/mslsub.c @@ -175,7 +175,7 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim, emp_initque(list); snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (!plane.pln_own) continue; @@ -198,7 +198,7 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim, if (plane.pln_effic < 100) continue; /* got a valid interceptor */ - irv = (struct plist *)malloc(sizeof(*irv)); + irv = malloc(sizeof(*irv)); irv->state = P_OK; irv->bombs = 0; irv->misc = 0; @@ -267,7 +267,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget, pcp = ip->pcp; if (mission_pln_equip(ip, 0, 0, 'i') < 0) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } /* got one interceptor, delete from irv_list and @@ -286,7 +286,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget, pcp = ip->pcp; if (mission_pln_equip(ip, 0, 0, 'i') < 0) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } /* got one interceptor, delete from irv_list and @@ -301,7 +301,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget, while (!QEMPTY(irvlist)) { qp = irvlist->q_forw; emp_remque(qp); - free((s_char *)qp); + free(qp); } if (icount == 0) { if (sect.sct_own != 0) @@ -348,7 +348,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget, pp->pln_own = 0; putplane(pp->pln_uid, pp); emp_remque(qp); - free((s_char *)qp); + free(qp); if (destroyed) break; } @@ -356,7 +356,7 @@ msl_intercept(coord x, coord y, natid bombown, int hardtarget, while (!QEMPTY(intlist)) { qp = intlist->q_forw; emp_remque(qp); - free((s_char *)qp); + free(qp); } if (destroyed) return (destroyed); diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index c744661f6..71a41eb61 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -339,7 +339,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap, unsigned int x; emp_initque(list); - while (nxtitem(ni, (s_char *)&plane)) { + while (nxtitem(ni, &plane)) { if (!player->owner) continue; if (plane.pln_mobil <= 0) @@ -503,7 +503,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap, pr("%s standing by\n", prplane(&plane)); plane.pln_mission = 0; putplane(plane.pln_uid, &plane); - plp = (struct plist *)malloc(sizeof(struct plist)); + plp = malloc(sizeof(struct plist)); plp->state = P_OK; plp->misc = 0; plp->bombs = 0; @@ -526,7 +526,7 @@ pln_arm(struct emp_qelem *list, int dist, int mission, struct ichrstr *ip, plp = (struct plist *)qp; if (pln_equip(plp, ip, flags, mission) < 0) { emp_remque(qp); - free((s_char *)qp); + free(qp); continue; } if (flags & (P_S | P_I)) { @@ -732,7 +732,7 @@ pln_put(struct emp_qelem *list) putplane(pp->pln_uid, pp); newqp = qp->q_forw; emp_remque(qp); - free((s_char *)qp); + free(qp); qp = newqp; } } @@ -759,7 +759,7 @@ pln_removedupes(struct emp_qelem *bomb_list, struct emp_qelem *esc_list) escp = (struct plist *)esc; if (escp->plane.pln_uid == bombp->plane.pln_uid) { emp_remque(esc); - free((s_char *)esc); + free(esc); esc = esc_list; } else esc = esc->q_forw; @@ -991,7 +991,7 @@ count_planes(struct shpstr *sp) mcp = &mchr[(int)sp->shp_type]; snxtitem_xy(&ni, EF_PLANE, sp->shp_x, sp->shp_y); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_ship == sp->shp_uid) { @@ -1025,7 +1025,7 @@ count_land_planes(struct lndstr *lp) return; snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_own == 0) continue; if (plane.pln_land == lp->lnd_uid) @@ -1046,7 +1046,7 @@ count_sect_planes(struct sctstr *sp) struct plnstr plane; snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (!plane.pln_own) continue; if (plane.pln_flags & PLN_LAUNCHED) diff --git a/src/lib/subs/pr.c b/src/lib/subs/pr.c index 8ea260c6a..a5dd8c7f3 100644 --- a/src/lib/subs/pr.c +++ b/src/lib/subs/pr.c @@ -246,7 +246,7 @@ pr_hilite(s_char *buf) register s_char c; s_char *p; - p = (s_char *)malloc(strlen(buf) + 1); + p = malloc(strlen(buf) + 1); strcpy(p, buf); for (bp = p; 0 != (c = *bp); bp++) if (isprint(c)) diff --git a/src/lib/subs/radmap.c b/src/lib/subs/radmap.c index b17d28013..c3e565db7 100644 --- a/src/lib/subs/radmap.c +++ b/src/lib/subs/radmap.c @@ -87,20 +87,20 @@ radmap2(int owner, int changed = 0; if (!radbuf) - radbuf = (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * + radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); if (!visbuf) - visbuf = (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * + visbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); if (!rad) { - rad = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + rad = malloc(WORLD_Y * sizeof(s_char *)); if (rad && radbuf) { for (x = 0; x < WORLD_Y; x++) rad[x] = &radbuf[(WORLD_X + 1) * x]; } } if (!vis) { - vis = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + vis = malloc(WORLD_Y * sizeof(s_char *)); if (vis && visbuf) { for (x = 0; x < WORLD_Y; x++) vis[x] = &visbuf[(WORLD_X + 1) * x]; diff --git a/src/lib/subs/retreat.c b/src/lib/subs/retreat.c index 0ed67b0bb..99b0cdd9d 100644 --- a/src/lib/subs/retreat.c +++ b/src/lib/subs/retreat.c @@ -101,7 +101,7 @@ retreat_ship(struct shpstr *sp, s_char code) buf[0] = sp->shp_fleet; buf[1] = 0; snxtitem(&ni, EF_SHIP, buf); - while (nxtitem(&ni, (s_char *)&ship)) + while (nxtitem(&ni, &ship)) if ((ship.shp_fleet == buf[0]) && (ship.shp_own == sp->shp_own)) { if (ship.shp_uid == sp->shp_uid) { @@ -402,7 +402,7 @@ retreat_land(struct lndstr *lp, s_char code) buf[0] = lp->lnd_army; buf[1] = 0; snxtitem(&ni, EF_SHIP, buf); - while (nxtitem(&ni, (s_char *)&land)) + while (nxtitem(&ni, &land)) if ((land.lnd_army == buf[0]) && (land.lnd_own == lp->lnd_own)) { if (land.lnd_uid == lp->lnd_uid) { retreat_land1(lp, code, 1); diff --git a/src/lib/subs/satmap.c b/src/lib/subs/satmap.c index 4e95a1c36..569a5637a 100644 --- a/src/lib/subs/satmap.c +++ b/src/lib/subs/satmap.c @@ -70,10 +70,10 @@ satmap(int x, int y, int eff, int range, int flags, int type) return; if (!radbuf) - radbuf = (s_char *)malloc((WORLD_Y * (WORLD_X + 1)) * + radbuf = malloc((WORLD_Y * (WORLD_X + 1)) * sizeof(s_char)); if (!rad) { - rad = (s_char **)malloc(WORLD_Y * sizeof(s_char *)); + rad = malloc(WORLD_Y * sizeof(s_char *)); if (rad && radbuf) { for (rx = 0; rx < WORLD_Y; rx++) rad[rx] = &radbuf[(WORLD_X + 1) * rx]; diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 4b0533b1f..27e8296de 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -71,7 +71,7 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list) struct mlist *mlp; emp_initque(list); - while (nxtitem(ni, (s_char *)&ship)) { + while (nxtitem(ni, &ship)) { if (!player->owner) continue; mcp = &mchr[(int)ship.shp_type]; @@ -103,7 +103,7 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list) ship.shp_rflags = 0; memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath)); putship(ship.shp_uid, &ship); - mlp = (struct mlist *)malloc(sizeof(struct mlist)); + mlp = malloc(sizeof(struct mlist)); mlp->mcp = mcp; mlp->ship = ship; mlp->mobil = (double)ship.shp_mobil; @@ -136,7 +136,7 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp, mpr(actor, "%s was sunk at %s\n", prship(&ship), xyas(ship.shp_x, ship.shp_y, actor)); emp_remque((struct emp_qelem *)mlp); - free((s_char *)mlp); + free(mlp); continue; } if (opt_SAIL) { @@ -203,7 +203,7 @@ shp_put(struct emp_qelem *list, natid actor) putship(mlp->ship.shp_uid, &mlp->ship); newqp = qp->q_back; emp_remque(qp); - free((s_char *)qp); + free(qp); qp = newqp; } } @@ -264,7 +264,7 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, natid actor) if (shp_check_one_mines(mlp)) { stopping = 1; emp_remque(qp); - free((s_char *)qp); + free(qp); } putship(mlp->ship.shp_uid, &mlp->ship); putsect(§); @@ -294,7 +294,7 @@ shp_check_one_mines(struct mlist *mlp) if (changed) writemap(actor); putsect(§); - putship(mlp->ship.shp_uid, (s_char *)&mlp->ship); + putship(mlp->ship.shp_uid, &mlp->ship); if (!mlp->ship.shp_own) return 1; } @@ -315,7 +315,7 @@ shp_check_mines(struct emp_qelem *ship_list) if (shp_check_one_mines(mlp)) { stopping = 1; emp_remque(qp); - free((s_char *)qp); + free(qp); } } return stopping; @@ -363,7 +363,7 @@ shp_mess(s_char *str, struct mlist *mlp) mlp->ship.shp_mobil = (int)mlp->mobil; putship(mlp->ship.shp_uid, &mlp->ship); emp_remque((struct emp_qelem *)mlp); - free((s_char *)mlp); + free(mlp); } static int @@ -417,7 +417,7 @@ shp_damage_one(struct mlist *mlp, int dam) putship(mlp->ship.shp_uid, &mlp->ship); if (!mlp->ship.shp_own) { emp_remque((struct emp_qelem *)mlp); - free((s_char *)mlp); + free(mlp); } } @@ -1008,8 +1008,8 @@ shp_path(int together, struct shpstr *shp, s_char *buf) return 0; } - cp = (s_char *)BestShipPath(buf, shp->shp_x, shp->shp_y, - d_sect.sct_x, d_sect.sct_y, player->cnum); + cp = BestShipPath(buf, shp->shp_x, shp->shp_y, + d_sect.sct_x, d_sect.sct_y, player->cnum); if (!cp || shp->shp_mobil <= 0) { mpr(shp->shp_own, "Can't get to '%s' right now.\n", xyas(d_sect.sct_x, d_sect.sct_y, player->cnum)); @@ -1029,7 +1029,7 @@ shp_missdef(struct shpstr *sp, natid victim) emp_initque(&list); - mlp = (struct mlist *)malloc(sizeof(struct mlist)); + mlp = malloc(sizeof(struct mlist)); mlp->mcp = &mchr[(int)sp->shp_type]; mlp->ship = *sp; mlp->mobil = (double)sp->shp_mobil; diff --git a/src/lib/subs/supply.c b/src/lib/subs/supply.c index fcf42f1cc..8741657d6 100644 --- a/src/lib/subs/supply.c +++ b/src/lib/subs/supply.c @@ -262,7 +262,7 @@ s_commod(int own, int x, int y, i_type type, int total_wanted, /* look for an owned ship in a harbor */ snxtitem_dist(&ni, EF_SHIP, x, y, lookrange); - while (nxtitem(&ni, (s_char *)&ship) && wanted) { + while (nxtitem(&ni, &ship) && wanted) { if (ship.shp_own != own) continue; @@ -335,7 +335,7 @@ s_commod(int own, int x, int y, i_type type, int total_wanted, /* look for an owned supply unit */ snxtitem_dist(&ni, EF_LAND, x, y, lookrange); - while (nxtitem(&ni, (s_char *)&land) && wanted) { + while (nxtitem(&ni, &land) && wanted) { int min; if (land.lnd_own != own) diff --git a/src/lib/subs/trdsub.c b/src/lib/subs/trdsub.c index 72cbdd26f..eaf98a0ef 100644 --- a/src/lib/subs/trdsub.c +++ b/src/lib/subs/trdsub.c @@ -139,7 +139,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp) pr("] #%d", tp->trd_unitid); if (opt_SHOWPLANE) { snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_ship == sp->shp_uid && plane.pln_own != 0) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, @@ -151,7 +151,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp) } } snxtitem_all(&ni, EF_LAND); - while (nxtitem(&ni, (s_char *)&land)) { + while (nxtitem(&ni, &land)) { if (land.lnd_ship == sp->shp_uid && land.lnd_own != 0) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", land.lnd_tech, @@ -159,7 +159,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp) lchr[(int)land.lnd_type].l_name, land.lnd_uid); if (land.lnd_nxlight) { snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_land == land.lnd_uid) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, @@ -197,7 +197,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp) pr("] #%d", tp->trd_unitid); if (opt_SHOWPLANE) { snxtitem_all(&ni, EF_PLANE); - while (nxtitem(&ni, (s_char *)&plane)) { + while (nxtitem(&ni, &plane)) { if (plane.pln_land == lp->lnd_uid && plane.pln_own != 0) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, @@ -233,7 +233,7 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp) int trade_getitem(struct trdstr *tp, union trdgenstr *tgp) { - if (!ef_read(tp->trd_type, tp->trd_unitid, (s_char *)tgp)) + if (!ef_read(tp->trd_type, tp->trd_unitid, tgp)) return 0; return 1; } diff --git a/src/lib/subs/trechk.c b/src/lib/subs/trechk.c index dfd9c4798..c463fd449 100644 --- a/src/lib/subs/trechk.c +++ b/src/lib/subs/trechk.c @@ -72,7 +72,7 @@ trechk(register natid actor, register natid victim, int provision) for (cn = 0; cn < MAXNOC; cn++) involved[cn] = 0; snxtitem_all(&nstr, EF_TREATY); - while (nxtitem(&nstr, (s_char *)&treaty)) { + while (nxtitem(&nstr, &treaty)) { if (treaty.trt_status == TS_FREE) continue; if (treaty.trt_exp < now) diff --git a/src/lib/update/finish.c b/src/lib/update/finish.c index 36fbe08f7..baf202c22 100644 --- a/src/lib/update/finish.c +++ b/src/lib/update/finish.c @@ -148,7 +148,7 @@ finish_sects(int etu) if (sp->sct_type == SCT_WATER || sp->sct_own == 0) { #ifdef SAVE_FINISH_PATHS if (infptr->path) - free((s_char *)infptr->path); + free(infptr->path); #endif /* SAVE_FINISH_PATHS */ continue; } @@ -156,7 +156,7 @@ finish_sects(int etu) if (np->nat_money < 0) { #ifdef SAVE_FINISH_PATHS if (infptr->path) - free((s_char *)infptr->path); + free(infptr->path); #endif /* SAVE_FINISH_PATHS */ continue; } @@ -164,7 +164,7 @@ finish_sects(int etu) infptr->path, infptr->imcost, infptr->excost); #ifdef SAVE_FINISH_PATHS if (infptr->path) - free((s_char *)infptr->path); + free(infptr->path); #endif /* SAVE_FINISH_PATHS */ } logerror("done importing\n"); @@ -205,7 +205,7 @@ assemble_dist_paths(struct distinfo *distptrs) int len; /* Here we malloc a buffer and save it */ len = strlen(path); - infptr->path = (s_char *)malloc(len); + infptr->path = malloc(len); if (infptr->path == (s_char *)0) { logerror("malloc failed in assemble_dist_path!\n"); return; diff --git a/src/lib/update/main.c b/src/lib/update/main.c index 3409df836..0c265e2da 100644 --- a/src/lib/update/main.c +++ b/src/lib/update/main.c @@ -95,7 +95,7 @@ update_main(void *unused) memset(air_money, 0, sizeof(air_money)); memset(sea_money, 0, sizeof(sea_money)); memset(lnd_money, 0, sizeof(lnd_money)); - bp = (int *)calloc(WORLD_X * WORLD_Y * 7, sizeof(int)); + bp = calloc(WORLD_X * WORLD_Y * 7, sizeof(int)); for (n = 0; n < MAXNOC; n++) { money[n] = 0; if ((np = getnatp(n)) == (struct natstr *)0) diff --git a/src/lib/update/nav_ship.c b/src/lib/update/nav_ship.c index d808d6035..ee38cb96a 100644 --- a/src/lib/update/nav_ship.c +++ b/src/lib/update/nav_ship.c @@ -258,7 +258,7 @@ nav_ship(struct shpstr *sp) /* Make a list of one ships so we can use the navi.c code */ emp_initque(&ship_list); - mlp = (struct mlist *)malloc(sizeof(struct mlist)); + mlp = malloc(sizeof(struct mlist)); mlp->mcp = mchr + sp->shp_type; mlp->ship = *sp; mlp->mobil = (double)sp->shp_mobil; diff --git a/src/lib/update/sail.c b/src/lib/update/sail.c index 339d6897b..a16931aed 100644 --- a/src/lib/update/sail.c +++ b/src/lib/update/sail.c @@ -167,7 +167,7 @@ sail_find_fleet(struct fltheadstr **head, struct shpstr *sp) fltp = fltp->next) ; if (!fltp) { - fltp = (struct fltheadstr *)malloc(sizeof(*fltp)); + fltp = malloc(sizeof(*fltp)); memset(fltp, 0, sizeof(*fltp)); /* Fix the links. */ @@ -192,7 +192,7 @@ sail_find_fleet(struct fltheadstr **head, struct shpstr *sp) return (0); } - this = (struct fltelemstr *)malloc(sizeof(*this)); + this = malloc(sizeof(*this)); memset(this, 0, sizeof(*this)); this->num = sp->shp_uid; this->own = sp->shp_own; @@ -338,7 +338,7 @@ fltp_to_list(struct fltheadstr *fltp, struct emp_qelem *list) emp_initque(list); for (fe = fltp->head; fe; fe = fe->next) { - mlp = (struct mlist *)malloc(sizeof(struct mlist)); + mlp = malloc(sizeof(struct mlist)); sp = getshipp(fe->num); mlp->mcp = mchr + sp->shp_type; mlp->ship = *sp; diff --git a/src/util/fairland.c b/src/util/fairland.c index e4b80ffda..088aca3c9 100644 --- a/src/util/fairland.c +++ b/src/util/fairland.c @@ -439,37 +439,36 @@ allocate_memory(void) return -1; } free(fname); - sectsbuf = - (struct sctstr *)calloc((YSIZE * XSIZE), sizeof(struct sctstr)); - sects = (struct sctstr **)calloc(YSIZE, sizeof(struct sctstr *)); + sectsbuf = calloc((YSIZE * XSIZE), sizeof(struct sctstr)); + sects = calloc(YSIZE, sizeof(struct sctstr *)); for (i = 0; i < YSIZE; i++) sects[i] = §sbuf[XSIZE * i]; - capx = (int *)calloc(nc, sizeof(int)); - capy = (int *)calloc(nc, sizeof(int)); - vector = (int *)calloc(WORLD_X + WORLD_Y, sizeof(int)); - mc = (int *)calloc(STABLE_CYCLE, sizeof(int)); - own = (int **)calloc(WORLD_X, sizeof(int *)); - elev = (int **)calloc(WORLD_X, sizeof(int *)); + capx = calloc(nc, sizeof(int)); + capy = calloc(nc, sizeof(int)); + vector = calloc(WORLD_X + WORLD_Y, sizeof(int)); + mc = calloc(STABLE_CYCLE, sizeof(int)); + own = calloc(WORLD_X, sizeof(int *)); + elev = calloc(WORLD_X, sizeof(int *)); for (i = 0; i < WORLD_X; ++i) { - own[i] = (int *)calloc(WORLD_Y, sizeof(int)); - elev[i] = (int *)calloc(WORLD_Y, sizeof(int)); + own[i] = calloc(WORLD_Y, sizeof(int)); + elev[i] = calloc(WORLD_Y, sizeof(int)); } - sectx = (int **)calloc(nc + ni, sizeof(int *)); - secty = (int **)calloc(nc + ni, sizeof(int *)); - sectc = (int **)calloc(nc + ni, sizeof(int *)); - isecs = (int *)calloc(nc + ni, sizeof(int)); - weight = (int *)calloc(max(sc, is * 2), sizeof(int)); - dsea = (int *)calloc(max(sc, is * 2), sizeof(int)); - dmoun = (int *)calloc(max(sc, is * 2), sizeof(int)); + sectx = calloc(nc + ni, sizeof(int *)); + secty = calloc(nc + ni, sizeof(int *)); + sectc = calloc(nc + ni, sizeof(int *)); + isecs = calloc(nc + ni, sizeof(int)); + weight = calloc(max(sc, is * 2), sizeof(int)); + dsea = calloc(max(sc, is * 2), sizeof(int)); + dmoun = calloc(max(sc, is * 2), sizeof(int)); for (i = 0; i < nc; ++i) { - sectx[i] = (int *)calloc(sc, sizeof(int)); - secty[i] = (int *)calloc(sc, sizeof(int)); - sectc[i] = (int *)calloc(sc, sizeof(int)); + sectx[i] = calloc(sc, sizeof(int)); + secty[i] = calloc(sc, sizeof(int)); + sectc[i] = calloc(sc, sizeof(int)); } for (i = nc; i < nc + ni; ++i) { - sectx[i] = (int *)calloc(is * 2, sizeof(int)); - secty[i] = (int *)calloc(is * 2, sizeof(int)); - sectc[i] = (int *)calloc(is * 2, sizeof(int)); + sectx[i] = calloc(is * 2, sizeof(int)); + secty[i] = calloc(is * 2, sizeof(int)); + sectc[i] = calloc(is * 2, sizeof(int)); } return 0; @@ -1163,10 +1162,10 @@ translate_continents(void) int i, j, n = 0, k, gotit, c; int *trans, *trans_cont, *oldcapx, *oldcapy; - trans = (int *)calloc(nc, sizeof(int)); - trans_cont = (int *)calloc(nc, sizeof(int)); - oldcapx = (int *)calloc(nc, sizeof(int)); - oldcapy = (int *)calloc(nc, sizeof(int)); + trans = calloc(nc, sizeof(int)); + trans_cont = calloc(nc, sizeof(int)); + oldcapx = calloc(nc, sizeof(int)); + oldcapy = calloc(nc, sizeof(int)); for (i = 0; i < WORLD_Y; ++i) { for (j = i % 2; j < WORLD_X; j += 2) { diff --git a/src/util/files.c b/src/util/files.c index 04e866b4f..e9f1685dd 100644 --- a/src/util/files.c +++ b/src/util/files.c @@ -174,11 +174,11 @@ main(int argc, char *argv[]) putsect(&sct); } } - map = (s_char *)calloc(WORLD_X * WORLD_Y / 2, sizeof(*map)); + map = calloc(WORLD_X * WORLD_Y / 2, sizeof(*map)); for (i = 0; i < MAXNOC; i++) { ef_write(EF_MAP, i, map); } - map = (s_char *)calloc(WORLD_X * WORLD_Y / 2, sizeof(*map)); + map = calloc(WORLD_X * WORLD_Y / 2, sizeof(*map)); for (i = 0; i < MAXNOC; i++) { ef_write(EF_BMAP, i, map); }