Remove a bunch of redundant casts.

This commit is contained in:
Markus Armbruster 2005-06-12 06:31:48 +00:00
parent ee6d72f3b8
commit 4f59fc9967
125 changed files with 417 additions and 432 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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,

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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;

View file

@ -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);

View file

@ -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)

View file

@ -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)

View file

@ -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) {

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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));*/

View file

@ -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)

View file

@ -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)

View file

@ -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);

View file

@ -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) {

View file

@ -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) {

View file

@ -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(&ltender, (s_char *)&item2))
if (!nxtitem(&ltender, &item2))
continue;
if (!(lchr[(int)item2.land.lnd_type].l_flags & L_SUPPLY)) {

View file

@ -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];

View file

@ -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;

View file

@ -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

View file

@ -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)

View file

@ -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];

View file

@ -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)

View file

@ -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++;
}

View file

@ -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)

View file

@ -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;
}

View file

@ -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)

View file

@ -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) {

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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];

View file

@ -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;

View file

@ -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)

View file

@ -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);

View file

@ -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);

View file

@ -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");

View file

@ -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)

View file

@ -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 *)&sect))
if (!ef_read(EF_SECTOR, id, &sect))
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;

View file

@ -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)

View file

@ -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)

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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, &sect);
if (sect.sct_own != player->cnum)
continue;

View file

@ -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++;

View file

@ -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) {

View file

@ -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];

View file

@ -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) {

View file

@ -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)) {

View file

@ -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];

View file

@ -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);

View file

@ -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);

View file

@ -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) {

View file

@ -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) {

View file

@ -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");

View file

@ -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)) {

View file

@ -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) {

View file

@ -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, &sect2);
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, &sect2);
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));

View file

@ -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, &sect);
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, &sect);
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);
}

View file

@ -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) {

View file

@ -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;
}
}

View file

@ -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, &sect);
@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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);
}

View file

@ -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];

View file

@ -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)

View file

@ -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) {

View file

@ -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)

View file

@ -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;

View file

@ -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++;

View file

@ -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;
}
}

View file

@ -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)

View file

@ -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) {

View file

@ -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;
}

View file

@ -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)

View file

@ -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++;
}

View file

@ -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, &sect);
@ -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, &sect);
@ -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, &sect);

View file

@ -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) {

View file

@ -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;
}
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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");

View file

@ -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;
}

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;
}

View file

@ -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();

View file

@ -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;

View file

@ -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;

Some files were not shown because too many files have changed in this diff Show more