diff --git a/include/misc.h b/include/misc.h index b6fb7000..1e841142 100644 --- a/include/misc.h +++ b/include/misc.h @@ -54,9 +54,6 @@ typedef unsigned int u_int; /* integral mismatch, due to misuse of sector short */ #pragma warning (disable : 4761 ) -#define bzero(d, s) memset(d, 0, s) -#define bcopy(s, d, z) memcpy(d, s, z) - #include #include diff --git a/src/client/host.c b/src/client/host.c index 5f308315..fe66d6cc 100644 --- a/src/client/host.c +++ b/src/client/host.c @@ -65,8 +65,7 @@ struct sockaddr_in *addr; fprintf(stderr, "%s: No such host\n", name); return 0; } - bcopy(hp->h_addr, (s_char *)&addr->sin_addr, - sizeof(addr->sin_addr)); + memcpy(&addr->sin_addr, hp->h_addr, sizeof(addr->sin_addr)); #ifdef _WIN32 printf("Trying to connect to '%s'\n", inet_ntoa(addr->sin_addr)); fflush(stdout); diff --git a/src/client/hpux.c b/src/client/hpux.c index 49bfac52..8071530f 100644 --- a/src/client/hpux.c +++ b/src/client/hpux.c @@ -63,18 +63,4 @@ register int c; return NULL; } -bzero(ptr, len) -s_char *ptr; -int len; -{ - memset(ptr, 0, len); -} - -bcopy(src, dst, len) -s_char *src; -s_char *dst; -int len; -{ - memcpy(dst, src, len); -} #endif diff --git a/src/client/ioqueue.c b/src/client/ioqueue.c index 7e084fb3..fd7babb4 100644 --- a/src/client/ioqueue.c +++ b/src/client/ioqueue.c @@ -218,7 +218,7 @@ int cc; if (nbytes > 0) { if (nleft < nbytes) nbytes = nleft; - bcopy(io->data + io->offset, offset, nbytes); + memcpy(offset, io->data + io->offset, nbytes); offset += nbytes; nleft -= nbytes; } diff --git a/src/client/login.c b/src/client/login.c index 46ca3837..cd95f5f2 100644 --- a/src/client/login.c +++ b/src/client/login.c @@ -96,7 +96,7 @@ int kill_proc; } (void)printf("\n"); (void)sendcmd(s, PASS, cpass); - bzero(cpass, strlen(cpass)); /* for core dumps */ + memset(cpass, 0, strlen(cpass)); /* for core dumps */ if (!expect(s, C_CMDOK, buf)) { (void)fprintf(stderr, "Bad password\n"); return 0; diff --git a/src/client/main.c b/src/client/main.c index ed8e4db4..80821f67 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -101,26 +101,6 @@ char c; return (s_char *)0; } -bzero(ptr, size) -s_char *ptr; -int size; -{ - int i; - - for (i = 0; i < size; i++) - ptr[i] = 0; -} - -bcopy(src, dest, size) -unsigned char *src, *dest; -int size; -{ - int i; - unsigned char *d = dest, *s = src; - - for (i = 0; i < size; i++) - *d++ = *s++; -} #endif int @@ -171,7 +151,7 @@ s_char *av[]; mask = bit_newfdmask(); savemask = bit_newfdmask(); #endif - bzero((s_char *)argv, sizeof(argv)); + memset(argv, 0, sizeof(argv)); saveargv(ac, av, argv); auxout_fname = 0; auxout_fp = 0; diff --git a/src/lib/as/as_cache.c b/src/lib/as/as_cache.c index dbfa266b..c3a12cf6 100644 --- a/src/lib/as/as_cache.c +++ b/src/lib/as/as_cache.c @@ -166,7 +166,7 @@ as_clear_cachepath() } /* Note we don't free the fromhead here, we just zero it. That way, we can use it next time without mallocing int */ - bzero((s_char *)fromhead, (sizeof(struct as_frompath *) * WORLD_Y)); + memset(fromhead, 0, (sizeof(struct as_frompath *) * WORLD_Y)); } struct as_path * diff --git a/src/lib/commands/add.c b/src/lib/commands/add.c index 91e736cd..53090a4b 100644 --- a/src/lib/commands/add.c +++ b/src/lib/commands/add.c @@ -207,7 +207,7 @@ add(void) natp->nat_xorg = 0; natp->nat_dayno = 0; natp->nat_minused = 0; - bzero((s_char *)natp->nat_b, sizeof(natp->nat_b)); + memset(natp->nat_b, 0, sizeof(natp->nat_b)); (void)time(&natp->nat_last_login); (void)time(&natp->nat_last_logout); natp->nat_money = 0; diff --git a/src/lib/commands/army.c b/src/lib/commands/army.c index 7da80b4f..77dfbfd3 100644 --- a/src/lib/commands/army.c +++ b/src/lib/commands/army.c @@ -76,7 +76,7 @@ army(void) while ((r = nxtitem(&ni, (s_char *)&land2)) && (land2.lnd_army != c)) ; if (r) { - bcopy(land2.lnd_rpath, land.lnd_rpath, 10); + memcpy(land.lnd_rpath, land2.lnd_rpath, sizeof(land.lnd_rpath)); land.lnd_rflags = land2.lnd_rflags; } putland(land.lnd_uid, &land); diff --git a/src/lib/commands/bomb.c b/src/lib/commands/bomb.c index 1cf4832d..2a8ecaa6 100644 --- a/src/lib/commands/bomb.c +++ b/src/lib/commands/bomb.c @@ -523,7 +523,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target) int gun; int shell; - bzero((s_char *)&head, sizeof(struct shiplook)); + memset(&head, 0, sizeof(struct shiplook)); head.uid = -1; onsea = (target->sct_type == SCT_WATER) ? 1 : 0; for (qp = list->q_forw; qp != list && !player->aborted; @@ -536,7 +536,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target) free(s2); } } - bzero((s_char *)&head, sizeof(struct shiplook)); + memset(&head, 0, sizeof(struct shiplook)); head.uid = -1; plp = (struct plist *)qp; if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T))) @@ -963,7 +963,7 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from, eff = pp->pln_effic; if (dam <= 0) return 0; - bzero(dmess, 255); + memset(dmess, 0, sizeof(dmess)); eff -= dam; if (eff < 0) eff = 0; diff --git a/src/lib/commands/budg.c b/src/lib/commands/budg.c index 66046bdd..c0d417f4 100644 --- a/src/lib/commands/budg.c +++ b/src/lib/commands/budg.c @@ -94,7 +94,7 @@ budg(void) s_char buf[1024]; s_char in[80]; - bzero((s_char *)p_sect, sizeof(p_sect)); + memset(p_sect, 0, sizeof(p_sect)); etu = etu_per_update; np = getnatp(player->cnum); diff --git a/src/lib/commands/buil.c b/src/lib/commands/buil.c index 9fb37fa5..de142330 100644 --- a/src/lib/commands/buil.c +++ b/src/lib/commands/buil.c @@ -416,7 +416,7 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp, if (freeship == 0) { ef_extend(EF_SHIP, 50); } - bzero(&ship, sizeof(struct shpstr)); + memset(&ship, 0, sizeof(struct shpstr)); ship.shp_x = sp->sct_x; ship.shp_y = sp->sct_y; ship.shp_destx[0] = sp->sct_x; @@ -572,7 +572,7 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp, if (freeland == 0) { ef_extend(EF_LAND, 50); } - bzero(&land, sizeof(struct lndstr)); + memset(&land, 0, sizeof(struct lndstr)); land.lnd_x = sp->sct_x; land.lnd_y = sp->sct_y; land.lnd_own = player->cnum; @@ -598,7 +598,7 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp, land.lnd_fuel = lp->l_fuelc; land.lnd_nxlight = 0; land.lnd_rflags = 0; - bzero(land.lnd_rpath, 10); + memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); land.lnd_rad_max = 0; land.lnd_nv = 0; land.lnd_att = (float)LND_ATTDEF(lp->l_att, tlev - lp->l_tech); @@ -636,7 +636,7 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp, vec[I_FOOD] -= max_amt; - bzero(lvec, sizeof(lvec)); + memset(lvec, 0, sizeof(lvec)); getvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND); lvec[I_FOOD] += max_amt; putvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND); @@ -937,7 +937,7 @@ build_plane(register struct sctstr *sp, register struct plchrstr *pp, if (freeplane == 0) { ef_extend(EF_PLANE, 50); } - bzero(&plane, sizeof(struct plnstr)); + memset(&plane, 0, sizeof(struct plnstr)); plane.pln_x = sp->sct_x; plane.pln_y = sp->sct_y; plane.pln_own = sp->sct_own; diff --git a/src/lib/commands/cede.c b/src/lib/commands/cede.c index 5cfd5ba5..a3f1dcb8 100644 --- a/src/lib/commands/cede.c +++ b/src/lib/commands/cede.c @@ -209,7 +209,7 @@ grab_sect(register struct sctstr *sp, natid to) int vec[I_MAX + 1]; /* Wipe all the distribution info */ - bzero((s_char *)vec, sizeof(vec)); + memset(vec, 0, sizeof(vec)); putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR); putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR); sp->sct_dist_x = sp->sct_x; diff --git a/src/lib/commands/coll.c b/src/lib/commands/coll.c index 532b4fb5..3e99cf0a 100644 --- a/src/lib/commands/coll.c +++ b/src/lib/commands/coll.c @@ -149,7 +149,7 @@ coll(void) makenotlost(EF_SECTOR, player->cnum, 0, sect.sct_x, sect.sct_y); sect.sct_own = player->cnum; - bzero((s_char *)vec, sizeof(vec)); + memset(vec, 0, sizeof(vec)); putvec(VT_DIST, vec, (s_char *)§, EF_SECTOR); putvec(VT_DEL, vec, (s_char *)§, EF_SECTOR); sect.sct_off = 1; diff --git a/src/lib/commands/cons.c b/src/lib/commands/cons.c index b0b713e3..4313a497 100644 --- a/src/lib/commands/cons.c +++ b/src/lib/commands/cons.c @@ -119,7 +119,7 @@ cons_choose(struct ltcomstr *ltcp) s_char prompt[128]; s_char buf[1024]; - bzero((s_char *)ltcp, sizeof(*ltcp)); + memset(ltcp, 0, sizeof(*ltcp)); if (getstarg(player->argp[1], "loan or treaty? ", buf) == 0) return RET_SYN; ltcp->type = ef_byname(buf); diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 42b88273..3e095475 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -800,7 +800,7 @@ doship(s_char op, int arg, s_char *p, struct shpstr *ship) putvar(V_PTIME, arg, (s_char *)ship, EF_SHIP); break; case 'R': - bcopy(p, ship->shp_rpath, 10); + memcpy(ship->shp_rpath, p, sizeof(ship->shp_rpath)); break; case 'W': ship->shp_rflags = arg; @@ -1041,7 +1041,7 @@ dounit(s_char op, int arg, s_char *p, struct lndstr *land) land->lnd_retreat = arg; break; case 'R': - bcopy(p, land->lnd_rpath, 10); + memcpy(land->lnd_rpath, p, sizeof(land->lnd_rpath)); break; case 'W': land->lnd_rflags = arg; diff --git a/src/lib/commands/expl.c b/src/lib/commands/expl.c index ce469aaa..17d95f58 100644 --- a/src/lib/commands/expl.c +++ b/src/lib/commands/expl.c @@ -53,7 +53,7 @@ int explore(void) { register int amount; - struct sctstr orig, sect; + struct sctstr sect; struct sctstr endsect; struct sctstr start; struct sctstr chksect; @@ -91,7 +91,6 @@ explore(void) pr("Not yours\n"); return RET_FAIL; } - bcopy((s_char *)§, (s_char *)&orig, sizeof(struct sctstr)); infected = getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT; if ((amt_src = getvar(vtype, (s_char *)§, EF_SECTOR)) <= 0) { pr("No %s in %s\n", ip->i_name, diff --git a/src/lib/commands/flee.c b/src/lib/commands/flee.c index 45d3baa3..80876b8b 100644 --- a/src/lib/commands/flee.c +++ b/src/lib/commands/flee.c @@ -76,7 +76,7 @@ flee(void) while ((r = nxtitem(&ni, (s_char *)&ship2)) && (ship2.shp_fleet != c)) ; if (r) { - bcopy(ship2.shp_rpath, ship.shp_rpath, 10); + memcpy(ship.shp_rpath, ship2.shp_rpath, sizeof(ship.shp_rpath)); ship.shp_rflags = ship2.shp_rflags; } putship(ship.shp_uid, &ship); diff --git a/src/lib/commands/head.c b/src/lib/commands/head.c index bea9fd0c..a3976879 100644 --- a/src/lib/commands/head.c +++ b/src/lib/commands/head.c @@ -90,7 +90,7 @@ head(void) pr("::::::::::::::::::::::::::::::::::::::::::::::::::\n"); pr(" %s", ctime(&now)); pr("\n"); - bzero((s_char *)hist, sizeof(hist)); + memset(hist, 0, sizeof(hist)); snxtitem_all(&nstr, EF_NEWS); maxcnum = 0; while (nxtitem(&nstr, (s_char *)&news)) { diff --git a/src/lib/commands/look.c b/src/lib/commands/look.c index 28e08710..b4e68189 100644 --- a/src/lib/commands/look.c +++ b/src/lib/commands/look.c @@ -69,7 +69,7 @@ look(void) pr("Memory error. Tell the deity.\n"); return RET_FAIL; } - bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); while (nxtitem(&ni, (s_char *)&myship)) { if (!player->owner) continue; @@ -195,7 +195,7 @@ llook(void) pr("Memory error. Tell the deity.\n"); return RET_FAIL; } - bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); while (nxtitem(&ni, (s_char *)&myland)) { if (!player->owner) continue; diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index 8e10e6aa..610542e9 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -694,7 +694,7 @@ defend(struct emp_qelem *al, struct emp_qelem *dl, enum targ_type target, if (nfiring > *nd) *nd = nfiring; fp = (struct flist *)malloc(sizeof(struct flist)); - bzero((s_char *)fp, sizeof(struct flist)); + memset(fp, 0, sizeof(struct flist)); fp->defdam = dam; fp->victim = vict; switch (attacker) { @@ -837,7 +837,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, (*nfiring)++; fp = (struct flist *)malloc(sizeof(struct flist)); - bzero((s_char *)fp, sizeof(struct flist)); + memset(fp, 0, sizeof(struct flist)); fp->type = targ_ship; fp->uid = ship.shp_uid; add_to_fired_queue(&fp->queue, list); @@ -869,7 +869,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, continue; (*nfiring)++; fp = (struct flist *)malloc(sizeof(struct flist)); - bzero((s_char *)fp, sizeof(struct flist)); + memset(fp, 0, sizeof(struct flist)); fp->type = targ_ship; fp->uid = ship.shp_uid; add_to_fired_queue(&fp->queue, list); @@ -922,7 +922,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, (*nfiring)++; fp = (struct flist *)malloc(sizeof(struct flist)); - bzero((s_char *)fp, sizeof(struct flist)); + memset(fp, 0, sizeof(struct flist)); fp->type = targ_unit; fp->uid = land.lnd_uid; add_to_fired_queue(&fp->queue, list); @@ -973,7 +973,7 @@ quiet_bigdef(int attacker, struct emp_qelem *list, natid own, natid aown, continue; (*nfiring)++; fp = (struct flist *)malloc(sizeof(struct flist)); - bzero((s_char *)fp, sizeof(struct flist)); + memset(fp, 0, sizeof(struct flist)); fp->x = firing.sct_x; fp->y = firing.sct_y; fp->type = targ_land; diff --git a/src/lib/commands/move.c b/src/lib/commands/move.c index dadf00e1..f60bb47d 100644 --- a/src/lib/commands/move.c +++ b/src/lib/commands/move.c @@ -394,14 +394,11 @@ want_to_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp) int would_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp) { - struct sctstr sect; int mil, civs, loyalcivs; if ((vtype != V_CIVIL) && (vtype != V_MILIT)) return 0; - bcopy((s_char *)sp, (s_char *)§, sizeof(struct sctstr)); - mil = getvar(V_MILIT, (s_char *)sp, EF_SECTOR); civs = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR); diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 5025572b..5468cba3 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -259,7 +259,7 @@ nav_map(int x, int y, int show_designations) logerror("malloc failed in navi\n"); return RET_FAIL; } - bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); /* zap any conditionals */ ns.ncond = 0; xyrelrange(np, &ns.range, &range); diff --git a/src/lib/commands/new.c b/src/lib/commands/new.c index c11ce30e..4a6aa96f 100644 --- a/src/lib/commands/new.c +++ b/src/lib/commands/new.c @@ -258,7 +258,7 @@ isok(int x, int y) pr("Memory error. Tell the deity.\n"); return 0; } - bzero((s_char *)map, (WORLD_X * WORLD_Y) / 2); + memset(map, 0, (WORLD_X * WORLD_Y) / 2); ok(map, x, y); free((s_char *)map); if (nfree < 5) @@ -360,7 +360,7 @@ deity_build_land(int type, coord x, coord y, natid own, int tlev) land.lnd_fuel = lp->l_fuelc; land.lnd_nxlight = 0; land.lnd_rflags = 0; - bzero((s_char *)land.lnd_rpath, 10); + memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); land.lnd_rad_max = lp->l_rad; land.lnd_nv = 0; @@ -381,7 +381,7 @@ deity_build_land(int type, coord x, coord y, natid own, int tlev) land.lnd_maxlight = (int)LND_XPL(lp->l_nxlight, tlev - lp->l_tech); land.lnd_maxland = (int)LND_MXL(lp->l_mxland, tlev - lp->l_tech); - bzero((s_char *)lvec, sizeof(lvec)); + memset(lvec, 0, sizeof(lvec)); getvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND); lvec[I_FOOD] += vl_find(V_FOOD, lp->l_vtype, lp->l_vamt, (int)lp->l_nv); diff --git a/src/lib/commands/news.c b/src/lib/commands/news.c index ddbf6a6b..6ecfbb0b 100644 --- a/src/lib/commands/news.c +++ b/src/lib/commands/news.c @@ -67,8 +67,8 @@ news(void) s_char num[128]; s_char *verb; - bzero((s_char *)page_has_news, sizeof(page_has_news)); - bzero((s_char *)sectors_taken, sizeof(sectors_taken)); + memset(page_has_news, 0, sizeof(page_has_news)); + memset(sectors_taken, 0, sizeof(sectors_taken)); (void)head(); (void)time(&now); natp = getnatp(player->cnum); diff --git a/src/lib/commands/path.c b/src/lib/commands/path.c index 963a2fe5..dcbf364a 100644 --- a/src/lib/commands/path.c +++ b/src/lib/commands/path.c @@ -105,8 +105,9 @@ path(void) xyrelrange(natp, &absrange, &relrange); blankfill((s_char *)mapbuf, &ns.range, 3); while (*pp && (i = chkdir(*pp, DIR_STOP, DIR_LAST)) >= 0) { - bcopy(routech[i][0], &map[deltay(cy, ns.range.ly)] - [deltax(cx, ns.range.lx) * 2], 3); + memcpy(&map[deltay(cy, ns.range.ly)][deltax(cx, ns.range.lx) * 2], + routech[i][0], + 3); cx += diroff[i][0]; cy += diroff[i][1]; ++pp; diff --git a/src/lib/commands/powe.c b/src/lib/commands/powe.c index 800ce8c2..039cced9 100644 --- a/src/lib/commands/powe.c +++ b/src/lib/commands/powe.c @@ -85,7 +85,7 @@ powe(void) int no_numbers = 0; s_char *p; - bzero((s_char *)targets, sizeof(targets)); + memset(targets, 0, sizeof(targets)); natp = getnatp(player->cnum); num = MAXNOC; if (player->argp[1] && player->argp[1][0] == 'n') { @@ -247,7 +247,7 @@ gen_power(void) float f; player->btused += powe_cost; - bzero((s_char *)powbuf, sizeof(powbuf)); + memset(powbuf, 0, sizeof(powbuf)); snxtsct_all(&ns); while (nxtsct(&ns, §)) { if (sect.sct_own == 0) diff --git a/src/lib/commands/rea.c b/src/lib/commands/rea.c index a6bb6de5..9d980b6b 100644 --- a/src/lib/commands/rea.c +++ b/src/lib/commands/rea.c @@ -80,7 +80,7 @@ rea(void) int first = 1; int readit; - bzero(kind, 80); + memset(kind, 0, sizeof(kind)); (void)time(&now); if (*player->argp[0] == 'w') { diff --git a/src/lib/commands/repo.c b/src/lib/commands/repo.c index f03b68ce..cb62bc62 100644 --- a/src/lib/commands/repo.c +++ b/src/lib/commands/repo.c @@ -76,7 +76,7 @@ repo(void) return RET_SYN; prdate(); natp = getnatp(player->cnum); - bzero((s_char *)&mystat, sizeof(struct stats)); + memset(&mystat, 0, sizeof(struct stats)); mystat.stat = natp->nat_stat; if (mystat.stat & STAT_NORM) { mystat.res = natp->nat_level[NAT_RLEV]; diff --git a/src/lib/commands/retr.c b/src/lib/commands/retr.c index 0812141b..ed1b3898 100644 --- a/src/lib/commands/retr.c +++ b/src/lib/commands/retr.c @@ -144,11 +144,10 @@ retr(void) continue; } if (zero) - bzero(ship.shp_rpath, RET_LEN); + memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath)); if (pq != (s_char *)0) { - bzero(ship.shp_rpath, RET_LEN); - bcopy(pq, ship.shp_rpath, strlen(pq)); + strncpy(ship.shp_rpath, pq, sizeof(ship.shp_rpath)); putship(ship.shp_uid, &ship); } if (rflags >= 0) { @@ -273,11 +272,10 @@ lretr(void) continue; } if (zero) - bzero(land.lnd_rpath, RET_LEN); + memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); if (pq != (s_char *)0) { - bzero(land.lnd_rpath, RET_LEN); - bcopy(pq, land.lnd_rpath, strlen(pq)); + strncpy(land.lnd_rpath, pq, sizeof(land.lnd_rpath)); putland(land.lnd_uid, &land); } if (rflags >= 0) { diff --git a/src/lib/commands/rout.c b/src/lib/commands/rout.c index 27e60097..22c3db7b 100644 --- a/src/lib/commands/rout.c +++ b/src/lib/commands/rout.c @@ -109,13 +109,12 @@ rout(void) return RET_FAIL; } ncond = ns.ncond; - bcopy((s_char *)ns.cond, (s_char *)cond, - sizeof(struct nscstr) * ncond); + memcpy(cond, ns.cond, sizeof(struct nscstr) * ncond); ns.ncond = 0; natp = getnatp(player->cnum); xyrelrange(natp, &ns.range, &relrange); - bzero((s_char *)mapbuf, ((WORLD_Y * MAPWIDTH(3)) * sizeof(s_char))); + memset(mapbuf, 0, ((WORLD_Y * MAPWIDTH(3)))); blankfill((s_char *)mapbuf, &ns.range, 3); border(&relrange, " ", " "); @@ -125,14 +124,14 @@ rout(void) p = &map[ns.dy][ns.dx * 2]; if ((dir = getvar(i_del, (s_char *)§, EF_SECTOR) & 0x7) && nstr_exec(cond, ncond, (s_char *)§, EF_SECTOR)) - bcopy(routech[dir][0], p, 3); + memcpy(p, routech[dir][0], 3); p[1] = dchr[sect.sct_type].d_mnem; } for (row = 0, y = ns.range.ly; row < ns.range.height; y++, row++) { ry = yrel(natp, y); - bzero(buf, (MAPWIDTH(3) + 10) * sizeof(s_char)); + memset(buf, 0, (MAPWIDTH(3) + 10)); sprintf(buf, "%4d ", ry); - bcopy(map[row], buf + 5, ns.range.width * 2 + 1); + memcpy(buf + 5, map[row], ns.range.width * 2 + 1); sprintf(buf + 5 + ns.range.width * 2 + 1, " %-4d\n", ry); pr("%s", buf); if (y >= WORLD_Y) diff --git a/src/lib/commands/sail.c b/src/lib/commands/sail.c index 19a9215b..3109b5e7 100644 --- a/src/lib/commands/sail.c +++ b/src/lib/commands/sail.c @@ -147,7 +147,6 @@ cmd_sail_ship(struct nstr_item *nstr) if (!check_ship_ok(&ship)) continue; if (!player->aborted) { - bzero(ship.shp_path, sizeof(ship.shp_path)); strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2); ship.shp_mission = 0; putship(ship.shp_uid, &ship); diff --git a/src/lib/commands/scra.c b/src/lib/commands/scra.c index 3f7ebddd..25c1ab5f 100644 --- a/src/lib/commands/scra.c +++ b/src/lib/commands/scra.c @@ -100,7 +100,7 @@ scra(void) || islist(p))) { s_char y_or_n[80], bbuf[80]; - bzero(y_or_n, 80); + memset(y_or_n, 0, sizeof(y_or_n)); if (type == EF_SHIP) { if (*p == '*') sprintf(bbuf, "all ships"); diff --git a/src/lib/commands/sect.c b/src/lib/commands/sect.c index 503d0f43..551fb3d9 100644 --- a/src/lib/commands/sect.c +++ b/src/lib/commands/sect.c @@ -102,7 +102,7 @@ sct(void) } np = getnatp(player->cnum); ncond = ns.ncond; - bcopy((s_char *)ns.cond, (s_char *)cond, sizeof(*cond) * ncond); + memcpy(cond, ns.cond, sizeof(*cond) * ncond); ns.ncond = 0; xyrelrange(getnatp(player->cnum), &ns.range, &range); border(&range, " ", ""); diff --git a/src/lib/commands/sona.c b/src/lib/commands/sona.c index 699f8187..8120f313 100644 --- a/src/lib/commands/sona.c +++ b/src/lib/commands/sona.c @@ -158,7 +158,7 @@ sona(void) rad[ns.dy][ns.dx], 0); } - bzero((s_char *)visbuf, (WORLD_Y * (WORLD_X + 1))); + memset(visbuf, 0, (WORLD_Y * (WORLD_X + 1))); snxtitem_dist(&nit, EF_SHIP, ship.shp_x, ship.shp_y, range); while (nxtitem(&nit, (caddr_t)&targ)) { diff --git a/src/lib/commands/spy.c b/src/lib/commands/spy.c index 54e29688..5e94c345 100644 --- a/src/lib/commands/spy.c +++ b/src/lib/commands/spy.c @@ -105,7 +105,7 @@ spy(void) * 6 = neighbors, 2 = x,y */ table = (coord *)malloc((nsects + 1) * 6 * 2 * sizeof(coord)); - bzero((s_char *)table, (nsects + 1) * 6 * 2 * sizeof(coord)); + memset(table, 0, (nsects + 1) * 6 * 2 * sizeof(coord)); pr("SPY report\n"); prdate(); pr(" old sct rd rl def\n"); diff --git a/src/lib/commands/surv.c b/src/lib/commands/surv.c index a6302dee..c83bd8f4 100644 --- a/src/lib/commands/surv.c +++ b/src/lib/commands/surv.c @@ -111,8 +111,7 @@ surv(void) return RET_FAIL; } ncond = nstr.ncond; - bcopy((s_char *)nstr.cond, (s_char *)cond, - sizeof(struct nscstr) * ncond); + memcpy(cond, nstr.cond, sizeof(struct nscstr) * ncond); nstr.ncond = 0; np = getnatp(player->cnum); xyrelrange(np, &nstr.range, &range); diff --git a/src/lib/commands/torp.c b/src/lib/commands/torp.c index 8e8b9658..d6b50b26 100644 --- a/src/lib/commands/torp.c +++ b/src/lib/commands/torp.c @@ -139,7 +139,6 @@ torp(void) pr("Ship #%d has insufficient mobility\n", sub.shp_uid); continue; } - bzero(buf, 80); subno = sub.shp_uid; sprintf(prompt, "Ship %d, target? ", sub.shp_uid); if ((ptr = getstarg(player->argp[2], prompt, buf)) == 0) diff --git a/src/lib/commands/wipe.c b/src/lib/commands/wipe.c index a5ebc2d5..83af3a7d 100644 --- a/src/lib/commands/wipe.c +++ b/src/lib/commands/wipe.c @@ -51,7 +51,7 @@ wipe(void) if (!snxtsct(&nstr, player->argp[1])) return RET_SYN; - bzero((s_char *)vec, sizeof(vec)); + memset(vec, 0, sizeof(vec)); while (nxtsct(&nstr, §)) { if (!player->owner) continue; diff --git a/src/lib/common/file.c b/src/lib/common/file.c index f8e3ad9b..677a456b 100644 --- a/src/lib/common/file.c +++ b/src/lib/common/file.c @@ -200,7 +200,7 @@ ef_read(int type, int id, caddr_t ptr) fillcache(ep, id); from = ep->cache + (id - ep->baseid) * ep->size; } - bcopy(from, ptr, ep->size); + memcpy(ptr, from, ep->size); if (ep->postread) ep->postread(id, ptr); @@ -290,7 +290,7 @@ ef_write(int type, int id, caddr_t ptr) if (id >= ep->baseid && id < ep->baseid + ep->cids) { /* update the cache if necessary */ to = ep->cache + (id - ep->baseid) * ep->size; - bcopy(ptr, to, ep->size); + memcpy(to, ptr, ep->size); } if (id > ep->fids) { logerror("WARNING ef_write: expanded %s by more than one id", diff --git a/src/lib/common/maps.c b/src/lib/common/maps.c index 59318979..9544a781 100644 --- a/src/lib/common/maps.c +++ b/src/lib/common/maps.c @@ -137,7 +137,7 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp, struct sctstr sect; if ((!player->god || country)) { - bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); bitinit2(nsp, bitmap, country); } while (nxtsct(nsp, §) && !player->aborted) { @@ -177,7 +177,7 @@ draw_map(int bmap, s_char origin, int map_flags, struct nstr_sect *nsp, int changed = 0; if ((!player->god || country)) { - bzero((s_char *)bitmap, (WORLD_X * WORLD_Y) / 8); + memset(bitmap, 0, (WORLD_X * WORLD_Y) / 8); bitinit2(nsp, bitmap, country); } while (nxtsct(nsp, §) && !player->aborted) { diff --git a/src/lib/common/path.c b/src/lib/common/path.c index c31fc725..3bba0d7a 100644 --- a/src/lib/common/path.c +++ b/src/lib/common/path.c @@ -115,7 +115,7 @@ bp_init(void) ep = &empfile[EF_SECTOR]; bp = (struct bestp *)malloc(sizeof(*bp)); - bzero((s_char *)bp, sizeof(*bp)); + memset(bp, 0, sizeof(*bp)); bp->adp = as_init(BP_NEIGHBORS, BP_ASHASHSIZE, bp_coord_hash, bp_neighbors, bp_lbcost, bp_realcost, bp_seccost, (s_char *)bp); diff --git a/src/lib/common/snxtit_subs.c b/src/lib/common/snxtit_subs.c index fbadfec2..1aa8b165 100644 --- a/src/lib/common/snxtit_subs.c +++ b/src/lib/common/snxtit_subs.c @@ -42,7 +42,7 @@ void snxtitem_area(register struct nstr_item *np, int type, struct range *range) { - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); np->cur = -1; np->type = type; np->sel = NS_AREA; @@ -60,7 +60,7 @@ snxtitem_dist(register struct nstr_item *np, int type, int cx, int cy, { struct range range; - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); xydist_range(cx, cy, dist, &range); np->cur = -1; np->type = type; @@ -83,7 +83,7 @@ snxtitem_dist(register struct nstr_item *np, int type, int cx, int cy, void snxtitem_xy(register struct nstr_item *np, int type, coord x, coord y) { - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); np->cur = -1; np->type = type; np->sel = NS_XY; @@ -99,7 +99,7 @@ snxtitem_xy(register struct nstr_item *np, int type, coord x, coord y) void snxtitem_all(register struct nstr_item *np, int type) { - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); np->cur = -1; np->sel = NS_ALL; np->type = type; @@ -115,7 +115,7 @@ snxtitem_group(register struct nstr_item *np, int type, s_char group) { if (group == '~') group = ' '; - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); np->cur = -1; np->sel = NS_GROUP; np->group = group; @@ -140,7 +140,7 @@ snxtitem_list(register struct nstr_item *np, int type, int *list, int len) { int i; - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); np->cur = -1; np->type = type; np->sel = NS_LIST; diff --git a/src/lib/common/snxtsct_subs.c b/src/lib/common/snxtsct_subs.c index 91025cad..853a9698 100644 --- a/src/lib/common/snxtsct_subs.c +++ b/src/lib/common/snxtsct_subs.c @@ -60,7 +60,7 @@ snxtsct_all(struct nstr_sect *np) void snxtsct_area(register struct nstr_sect *np, struct range *range) { - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); np->range = *range; np->ncond = 0; np->type = NS_AREA; @@ -87,7 +87,7 @@ snxtsct_rewind(struct nstr_sect *np) void snxtsct_dist(register struct nstr_sect *np, coord cx, coord cy, int dist) { - bzero((s_char *)np, sizeof(*np)); + memset(np, 0, sizeof(*np)); xydist_range(cx, cy, dist, &np->range); np->cx = cx; np->cy = cy; diff --git a/src/lib/gen/copy.c b/src/lib/gen/copy.c index 38c1f1ff..ce95aa0c 100644 --- a/src/lib/gen/copy.c +++ b/src/lib/gen/copy.c @@ -37,22 +37,6 @@ #include "gen.h" #include "optlist.h" -#ifdef hpux -#include - -void -bzero(s_char *ptr, int len) -{ - memset(ptr, 0, len); -} - -void -bcopy(s_char *src, s_char *dst, int len) -{ - memcpy(dst, src, len); -} -#endif - /* * space-fill a map or radar scan; * null terminate diff --git a/src/lib/gen/ioqueue.c b/src/lib/gen/ioqueue.c index c9c20114..02d80ed1 100644 --- a/src/lib/gen/ioqueue.c +++ b/src/lib/gen/ioqueue.c @@ -212,7 +212,7 @@ ioqtobuf(struct ioqueue *ioq, s_char *buf, int cc) if (nbytes > 0) { if (nleft < nbytes) nbytes = nleft; - bcopy(io->data + io->offset, offset, nbytes); + memcpy(offset, io->data + io->offset, nbytes); offset += nbytes; nleft -= nbytes; } @@ -312,7 +312,7 @@ appendcc(struct ioqueue *ioq, s_char *buf, int cc) if (avail > 0) { /* append to existing buffer */ len = cc > avail ? avail : cc; - bcopy(buf, io->data + io->nbytes, len); + memcpy(io->data + io->nbytes, buf, len); io->nbytes += len; ioq->cc += len; if (avail < cc) @@ -321,7 +321,7 @@ appendcc(struct ioqueue *ioq, s_char *buf, int cc) /* create a new buffer, minimum bufsize bytes */ len = cc > ioq->bufsize ? cc : ioq->bufsize; ptr = malloc(len); - bcopy(buf, ptr, cc); + memcpy(ptr, buf, cc); io = (struct io *)malloc(sizeof(struct io)); io->nbytes = cc; io->size = len; @@ -414,7 +414,7 @@ ioq_makebuf(struct ioqueue *ioq, char *pBuf, int nBufLen) if (nbytes > nleft) break; - bcopy(io->data + io->offset, offset, nbytes); + memcpy(offset, io->data + io->offset, nbytes); offset += nbytes; nleft -= nbytes; ncopied += nbytes; diff --git a/src/lib/lwp/arch.c b/src/lib/lwp/arch.c index b03774dd..c076c89b 100644 --- a/src/lib/lwp/arch.c +++ b/src/lib/lwp/arch.c @@ -326,7 +326,7 @@ void *sp; static jmp_buf *cpp; extern struct lwpProc *LwpCurrent; - bzero(newp->context, sizeof(newp->context)); + memset(newp->context, 0, sizeof(newp->context)); newp->context[0] = (int)sp; /* preserve cpp for new context */ cpp = (jmp_buf *) & newp->context; diff --git a/src/lib/lwp/sel.c b/src/lib/lwp/sel.c index 8a996568..0cc400e4 100644 --- a/src/lib/lwp/sel.c +++ b/src/lib/lwp/sel.c @@ -194,10 +194,8 @@ char **argv; } lwpStatus(us, "selecting; sleep %ld secs", (long)delta); - bcopy((s_char *)&LwpSelect.readmask, (s_char *)&readmask, - sizeof(fd_set)); - bcopy((s_char *)&LwpSelect.writemask, (s_char *)&writemask, - sizeof(fd_set)); + memcpy(&readmask, &LwpSelect.readmask, sizeof(fd_set)); + memcpy(&writemask, &LwpSelect.writemask, sizeof(fd_set)); n = select(LwpSelect.maxfd + 1, &readmask, &writemask, (fd_set *) 0, &tv); diff --git a/src/lib/player/accept.c b/src/lib/player/accept.c index 29d6560c..dbf2f980 100644 --- a/src/lib/player/accept.c +++ b/src/lib/player/accept.c @@ -77,8 +77,8 @@ player_new(int s, struct sockaddr_in *sin) struct player *lp; struct hostent *hostp; - lp = (struct player *)calloc(1, sizeof(struct player)); - bzero((s_char *)lp, sizeof(struct player)); + lp = (struct player *)malloc(sizeof(struct player)); + memset(lp, 0, sizeof(struct player)); if (sin) { /* update uses dummy player */ /* so does the market updater */ diff --git a/src/lib/subs/aircombat.c b/src/lib/subs/aircombat.c index aab0ca21..f7f2d3c4 100644 --- a/src/lib/subs/aircombat.c +++ b/src/lib/subs/aircombat.c @@ -110,19 +110,18 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, a sector, and then overfly some land units or ships, we don't want to potentially intercept 3 times. */ - bzero((s_char *)&head, sizeof(struct shiplook)); + memset(&head, 0, sizeof(struct shiplook)); head.uid = -1; plp = (struct plist *)bomb_list->q_forw; plane_owner = plp->plane.pln_own; - bzero((s_char *)mypath, 1024); - bcopy(path, mypath, strlen(path)); + strncpy(mypath, path, sizeof(mypath)); myp = 0; - bzero((s_char *)overfly, sizeof(overfly)); - bzero((s_char *)gotilist, sizeof(gotilist)); - bzero((s_char *)unfriendly, sizeof(unfriendly)); + memset(overfly, 0, sizeof(overfly)); + memset(gotilist, 0, sizeof(gotilist)); + memset(unfriendly, 0, sizeof(unfriendly)); for (cn = 1; cn < MAXNOC; cn++) { if ((mynatp = getnatp(cn)) == 0) continue; @@ -294,7 +293,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, /* Something made it through */ /* Go figure out if there are ships in this sector, and who's they are */ - bzero((s_char *)nats, sizeof(nats)); + memset(nats, 0, sizeof(nats)); snxtitem_xy(&ni, EF_SHIP, x, y); while (nxtitem(&ni, (s_char *)&ship)) { if (mchr[(int)ship.shp_type].m_flags & M_SUB) @@ -302,7 +301,7 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list, nats[ship.shp_own]++; } /* Go figure out if there are units in this sector, and who's they are */ - bzero((s_char *)lnats, sizeof(lnats)); + memset(lnats, 0, sizeof(lnats)); snxtitem_xy(&ni, EF_LAND, x, y); while (nxtitem(&ni, (s_char *)&land)) { lnats[land.lnd_own]++; @@ -736,7 +735,7 @@ ac_planedamage(struct plist *plp, natid from, int dam, natid other, strcpy(mesg, dmess); return; } - bzero(dmess, 255); + memset(dmess, 0, sizeof(dmess)); eff -= dam; if (eff < 0) eff = 0; @@ -850,7 +849,7 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y) plp = (struct plist *)list->q_forw; plane_owner = plp->plane.pln_own; - bzero((s_char *)nats, sizeof(nats)); + memset(nats, 0, sizeof(nats)); guns = 0; snxtitem_xy(&ni, EF_SHIP, x, y); while (!QEMPTY(list) && nxtitem(&ni, (s_char *)&ship)) { @@ -917,7 +916,7 @@ ac_landflak(struct emp_qelem *list, coord x, coord y) plp = (struct plist *)list->q_forw; plane_owner = plp->plane.pln_own; - bzero((s_char *)nats, sizeof(nats)); + memset(nats, 0, sizeof(nats)); guns = 0; snxtitem_xy(&ni, EF_LAND, x, y); while (!QEMPTY(list) && nxtitem(&ni, (s_char *)&land)) { @@ -1112,7 +1111,7 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a, ip->bombs = 0; ip->misc = 0; ip->pcp = &plchr[(int)plane.pln_type]; - bcopy((s_char *)&plane, (s_char *)&ip->plane, sizeof(plane)); + ip->plane = plane; emp_insque(&ip->queue, list); } } diff --git a/src/lib/subs/aswplnsubs.c b/src/lib/subs/aswplnsubs.c index 797f0eb2..a7dc836f 100644 --- a/src/lib/subs/aswplnsubs.c +++ b/src/lib/subs/aswplnsubs.c @@ -106,7 +106,7 @@ set_have_looked(u_char uid, struct shiplook *head) } s = (struct shiplook *)malloc(sizeof(struct shiplook)); - bzero((s_char *)s, sizeof(struct shiplook)); + memset(s, 0, sizeof(struct shiplook)); s2->next = s; s->uid = uid; s->looked = 1; @@ -137,7 +137,7 @@ set_have_found(u_char uid, struct shiplook *head) } s = (struct shiplook *)malloc(sizeof(struct shiplook)); - bzero((s_char *)s, sizeof(struct shiplook)); + memset(s, 0, sizeof(struct shiplook)); s2->next = s; s->uid = uid; s->found = 1; diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index ac28aacd..f8bd64b9 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -115,7 +115,7 @@ static int get_land(int combat_mode, struct combat *def, int uid, int att_combat_init(struct combat *com, int type) { - bzero((s_char *)com, sizeof(*com)); + memset(com, 0, sizeof(*com)); com->type = type; return type; } @@ -429,7 +429,7 @@ put_combat(struct combat *com) if (com->own == player->cnum) { land.lnd_mission = 0; land.lnd_rflags = 0; - bzero(land.lnd_rpath, RET_LEN); + memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); } putland(com->lnd_uid, &land); break; @@ -456,7 +456,7 @@ put_combat(struct combat *com) if (com->own == player->cnum) { ship.shp_mission = 0; ship.shp_rflags = 0; - bzero(ship.shp_rpath, RET_LEN); + memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath)); } putship(com->shp_uid, &ship); } @@ -832,7 +832,7 @@ att_ask_offense(int combat_mode, struct combat *off, struct combat *def, emp_initque(olist); if (att_abort(combat_mode, off, def)) return 0; - bzero(land_answer, sizeof(land_answer)); + memset(land_answer, 0, sizeof(land_answer)); for (n = 0; n <= off->last; ++n) { off[n].troops = ask_off(combat_mode, off + n, def); if (att_abort(combat_mode, off, def)) @@ -1126,7 +1126,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def, abort_attack(); return; } - bzero((s_char *)llp, sizeof(struct llist)); + memset(llp, 0, sizeof(struct llist)); emp_insque(&llp->queue, olist); llp->mobil = mobcost; if (!get_land(combat_mode, def, land.lnd_uid, llp, 0)) @@ -1292,7 +1292,7 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy, abort_attack(); return 0; } - bzero((s_char *)llp, sizeof(struct llist)); + memset(llp, 0, sizeof(struct llist)); emp_insque(&llp->queue, list); llp->supplied = has_supply(&land); if (!get_land(A_DEFEND, def, land.lnd_uid, llp, 1)) @@ -1629,13 +1629,12 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy, llp = (struct llist *) malloc(sizeof(struct llist)); - bzero((s_char *)llp, sizeof(struct llist)); + memset(llp, 0, sizeof(struct llist)); llp->supplied = supply_state; llp->x = origx; llp->y = origy; llp->lcp = &lchr[(int)land.lnd_type]; - bcopy((s_char *)&land, (s_char *)&llp->land, - sizeof(struct lndstr)); + llp->land = land; emp_insque(&llp->queue, list); if (lnd_spyval(&land) > *d_spyp) *d_spyp = lnd_spyval(&land); @@ -2372,7 +2371,7 @@ ask_move_in(struct combat *off, struct emp_qelem *olist, if (QEMPTY(olist)) return; - bzero(land_answer, sizeof(land_answer)); + memset(land_answer, 0, sizeof(land_answer)); for (qp = olist->q_forw; qp != olist; qp = next) { next = qp->q_forw; llp = (struct llist *)qp; diff --git a/src/lib/subs/land.c b/src/lib/subs/land.c index 7c0dfc1b..642e77da 100644 --- a/src/lib/subs/land.c +++ b/src/lib/subs/land.c @@ -55,7 +55,7 @@ lnd_postread(int n, s_char *ptr) if (llp->lnd_uid != n) { logerror("lnd_postread: Error - %d != %d, zeroing.\n", llp->lnd_uid, n); - bzero(ptr, sizeof(struct lndstr)); + memset(llp, 0, sizeof(struct lndstr)); } if (llp->lnd_ship >= 0 && llp->lnd_own && llp->lnd_effic >= LAND_MINEFF) { diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index 23fb4844..a4362181 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -383,9 +383,9 @@ intelligence_report(int destination, struct lndstr *lp, int spy, lcp = &lchr[(int)lp->lnd_type]; - bzero(buf1, 80); - bzero(buf2, 80); - bzero(buf3, 80); + memset(buf1, 0, sizeof(buf1)); + memset(buf2, 0, sizeof(buf2)); + memset(buf3, 0, sizeof(buf3)); if (chance((double)(spy + lp->lnd_vis) / 10.0)) { if (destination == player->cnum) pr("%s %s", mess, prland(lp)); @@ -559,12 +559,11 @@ lnd_sel(struct nstr_item *ni, struct emp_qelem *list) land.lnd_mission = 0; land.lnd_rflags = 0; land.lnd_harden = 0; - bzero(land.lnd_rpath, RET_LEN); + memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath)); putland(land.lnd_uid, &land); llp = (struct llist *)malloc(sizeof(struct llist)); llp->lcp = lcp; - bcopy((s_char *)&land, (s_char *)&llp->land, - sizeof(struct lndstr)); + llp->land = land; llp->mobil = (double)land.lnd_mobil; emp_insque(&llp->queue, list); } @@ -640,8 +639,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp, *minmobp = llp->mobil; if (llp->mobil > *maxmobp) *maxmobp = llp->mobil; - bcopy((s_char *)&land, (s_char *)&llp->land, - sizeof(struct lndstr)); + llp->land = land; } } diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index 8f080d46..f6873fa9 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -89,7 +89,7 @@ ground_interdict(coord x, coord y, natid victim, s_char *s) struct genlist mi[MAXNOC]; int z; - bzero((s_char *)mi, sizeof(mi)); + memset(mi, 0, sizeof(mi)); for (z = 1; z < MAXNOC; z++) emp_initque((struct emp_qelem *)&mi[z]); @@ -178,7 +178,7 @@ unit_interdict(coord x, coord y, natid victim, s_char *s, int hardtarget, int z; int osubs; - bzero((s_char *)mi, sizeof(mi)); + memset(mi, 0, sizeof(mi)); for (z = 1; z < MAXNOC; z++) emp_initque((struct emp_qelem *)&mi[z]); @@ -230,7 +230,7 @@ off_support(coord x, coord y, natid victim, natid actee) struct genlist mi[MAXNOC]; int z; - bzero((s_char *)mi, sizeof(mi)); + memset(mi, 0, sizeof(mi)); for (z = 1; z < MAXNOC; z++) emp_initque((struct emp_qelem *)&mi[z]); @@ -251,7 +251,7 @@ def_support(coord x, coord y, natid victim, natid actee) struct genlist mi[MAXNOC]; int z; - bzero((s_char *)mi, sizeof(mi)); + memset(mi, 0, sizeof(mi)); for (z = 1; z < MAXNOC; z++) emp_initque((struct emp_qelem *)&mi[z]); @@ -385,7 +385,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission, } glp = (struct genlist *)malloc(sizeof(struct genlist)); - bzero((s_char *)glp, sizeof(struct genlist)); + memset(glp, 0, sizeof(struct genlist)); glp->x = gp->x; glp->y = gp->y; glp->type = type; @@ -401,7 +401,7 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission, break; } glp->thing = (s_char *)malloc(size); - bcopy(block, glp->thing, size); + memcpy(glp->thing, block, size); emp_insque(&glp->queue, &mi[gp->own].queue); } } @@ -428,10 +428,9 @@ find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts) continue; plp = (struct plist *)malloc(sizeof(struct plist)); - bzero((s_char *)plp, sizeof(struct plist)); + memset(plp, 0, sizeof(struct plist)); plp->pcp = &plchr[(int)plane.pln_type]; - bcopy((s_char *)&plane, (s_char *)&plp->plane, - sizeof(struct plnstr)); + plp->plane = plane; emp_insque(&plp->queue, escorts); } } @@ -673,10 +672,9 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list, /* save planes for later */ plp = (struct plist *)malloc(sizeof(struct plist)); - bzero((s_char *)plp, sizeof(struct plist)); + memset(plp, 0, sizeof(struct plist)); plp->pcp = pcp; - bcopy(glp->thing, (s_char *)&plp->plane, - sizeof(struct plnstr)); + memcpy(&plp->plane, glp->thing, sizeof(struct plnstr)); if (plp->pcp->pl_flags & P_M) emp_insque(&plp->queue, &missiles); else @@ -1553,7 +1551,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list, for (qp = esc_list->q_forw; qp != esc_list; qp = qp->q_forw) count++; - bzero((s_char *)mi, sizeof(mi)); + memset(mi, 0, sizeof(mi)); for (z = 1; z < MAXNOC; z++) emp_initque((struct emp_qelem *)&mi[z]); @@ -1582,10 +1580,9 @@ 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)); - bzero((s_char *)plp, sizeof(struct plist)); + memset(plp, 0, sizeof(struct plist)); plp->pcp = (struct plchrstr *)glp->cp; - bcopy(glp->thing, (s_char *)&plp->plane, - sizeof(struct plnstr)); + memcpy(&plp->plane, glp->thing, sizeof(struct plnstr)); /* missiles go one way, so we can use all the range */ if (!(plp->pcp->pl_flags & P_M)) diff --git a/src/lib/subs/move.c b/src/lib/subs/move.c index 4204c082..e435d03b 100644 --- a/src/lib/subs/move.c +++ b/src/lib/subs/move.c @@ -96,8 +96,7 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end, else { pr("Using best path '%s', movement cost %1.3f\n", path, total_mcost); - bzero(bpath, 512); - bcopy(path, bpath, strlen(path)); + strncpy(bpath, path, sizeof(bpath)); path = bpath; } if ((total_mcost * weight) > mobility) { @@ -152,8 +151,7 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end, } else { pr("Using best path '%s', movement cost %1.3f\n", movstr, mv_cost); - bzero(bpath, 512); - bcopy(movstr, bpath, strlen(movstr)); + strncpy(bpath, movstr, sizeof(bpath)); movstr = bpath; } } diff --git a/src/lib/subs/mslsub.c b/src/lib/subs/mslsub.c index 7b4589de..3db0927a 100644 --- a/src/lib/subs/mslsub.c +++ b/src/lib/subs/mslsub.c @@ -57,9 +57,9 @@ msl_equip(struct plnstr *pp) { struct plist pl; - bzero((s_char *)&pl, sizeof(struct plist)); + memset(&pl, 0, sizeof(struct plist)); pl.pcp = plchr + pp->pln_type; - bcopy((s_char *)pp, (s_char *)&pl.plane, sizeof(struct plnstr)); + pl.plane = *pp; return mission_pln_equip(&pl, 0, 0, 'p'); } @@ -210,7 +210,7 @@ msl_sel(struct emp_qelem *list, coord x, coord y, natid victim, irv->bombs = 0; irv->misc = 0; irv->pcp = &plchr[(int)plane.pln_type]; - bcopy((s_char *)&plane, (s_char *)&irv->plane, sizeof(plane)); + irv->plane = plane; emp_insque(&irv->queue, list); } } diff --git a/src/lib/subs/nuke.c b/src/lib/subs/nuke.c index 827af3e7..6f2e7c81 100644 --- a/src/lib/subs/nuke.c +++ b/src/lib/subs/nuke.c @@ -53,7 +53,7 @@ nuk_postread(int n, s_char *ptr) if (np->nuk_uid != n) { logerror("nuk_postread: Error - %d != %d, zeroing.\n", np->nuk_uid, n); - bzero(ptr, sizeof(struct nukstr)); + memset(np, 0, sizeof(struct nukstr)); } player->owner = (player->god || np->nuk_own == player->cnum); return 1; @@ -119,7 +119,7 @@ nuk_add(coord x, coord y, int type, int num) nuk_uid = n; if (getnuke(nuk_uid, &nuke) == 0) { ef_extend(EF_NUKE, 10); - bzero((s_char *)&nuke, sizeof(struct nukstr)); + memset(&nuke, 0, sizeof(struct nukstr)); nuke.nuk_uid = nuk_uid; nuke.nuk_ship = -1; nuke.nuk_n = 0; diff --git a/src/lib/subs/plane.c b/src/lib/subs/plane.c index 8f0eb1ff..73c8923d 100644 --- a/src/lib/subs/plane.c +++ b/src/lib/subs/plane.c @@ -55,7 +55,7 @@ pln_postread(int n, s_char *ptr) if (pp->pln_uid != n) { logerror("pln_postread: Error - %d != %d, zeroing.\n", pp->pln_uid, n); - bzero(ptr, sizeof(struct plnstr)); + memset(pp, 0, sizeof(struct plnstr)); } if (pp->pln_ship >= 0 && pp->pln_own && pp->pln_effic >= PLANE_MINEFF) { diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index d5fa20b7..ac3f6abe 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -460,8 +460,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap, plp->misc = 0; plp->bombs = 0; plp->pcp = pcp; - bcopy((s_char *)&plane, (s_char *)&plp->plane, - sizeof(struct plnstr)); + plp->plane = plane; emp_insque(&plp->queue, list); } } diff --git a/src/lib/subs/radmap.c b/src/lib/subs/radmap.c index 913bba95..bfad771a 100644 --- a/src/lib/subs/radmap.c +++ b/src/lib/subs/radmap.c @@ -112,7 +112,7 @@ radmap2(int owner, return; } - bzero((s_char *)visbuf, (WORLD_Y * (WORLD_X + 1))); + memset(visbuf, 0, (WORLD_Y * (WORLD_X + 1))); range = (int)(range * (eff / 100.0)); if (range < 1) range = 1; diff --git a/src/lib/subs/retreat.c b/src/lib/subs/retreat.c index b10511be..743c1406 100644 --- a/src/lib/subs/retreat.c +++ b/src/lib/subs/retreat.c @@ -32,6 +32,7 @@ * */ +#include #include "misc.h" #include "player.h" #include "nat.h" @@ -100,8 +101,8 @@ retreat_ship(struct shpstr *sp, s_char code) s_char buf[2]; if (sp->shp_rflags & RET_GROUP) { - bzero(buf, 2); buf[0] = sp->shp_fleet; + buf[1] = 0; snxtitem(&ni, EF_SHIP, buf); while (nxtitem(&ni, (s_char *)&ship)) if ((ship.shp_fleet == buf[0]) && @@ -149,7 +150,6 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig) struct mchrstr *mcp; int vec[I_MAX + 1]; int time_to_stop; - s_char buf[RET_LEN - 1]; sp->shp_mission = 0; if (sp->shp_own == 0) @@ -247,10 +247,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig) return 0; } dir = chkdir(sp->shp_rpath[0], DIR_STOP, DIR_VIEW); - bzero(buf, RET_LEN - 1); - bcopy(&sp->shp_rpath[1], buf, RET_LEN - 1); - bzero(sp->shp_rpath, RET_LEN); - bcopy(buf, sp->shp_rpath, RET_LEN - 1); + memmove(sp->shp_rpath, sp->shp_rpath+1, sizeof(sp->shp_rpath) - 1); if (dir == -1) continue; if (dir == DIR_STOP) @@ -397,8 +394,8 @@ retreat_land(struct lndstr *lp, s_char code) s_char buf[2]; if (lp->lnd_rflags & RET_GROUP) { - bzero(buf, 2); buf[0] = lp->lnd_army; + buf[1] = 0; snxtitem(&ni, EF_SHIP, buf); while (nxtitem(&ni, (s_char *)&land)) if ((land.lnd_army == buf[0]) && (land.lnd_own == lp->lnd_own)) { @@ -492,10 +489,7 @@ retreat_land1(struct lndstr *lp, s_char code, int orig) return 0; } dir = chkdir(lp->lnd_rpath[0], DIR_STOP, DIR_VIEW); - bzero(buf, RET_LEN - 1); - bcopy(&lp->lnd_rpath[1], buf, RET_LEN - 1); - bzero(lp->lnd_rpath, RET_LEN); - bcopy(buf, lp->lnd_rpath, RET_LEN - 1); + memmove(lp->lnd_rpath, lp->lnd_rpath+1, sizeof(lp->lnd_rpath) - 1); if (dir == -1) continue; if (dir == DIR_STOP) diff --git a/src/lib/subs/satmap.c b/src/lib/subs/satmap.c index 8947418c..95325bcd 100644 --- a/src/lib/subs/satmap.c +++ b/src/lib/subs/satmap.c @@ -91,7 +91,7 @@ satmap(int x, int y, int eff, int range, int flags, int type) range = range * (eff / 100.0); pr("%s efficiency %d%%, max range %d\n", xyas(x, y, player->cnum), eff, range); - bzero(noise, sizeof(noise)); + memset(noise, 0, sizeof(noise)); if (eff < 100) { pr("Some noise on the transmission...\n"); for (n = 0; n < (100 - eff); ++n) diff --git a/src/lib/subs/ship.c b/src/lib/subs/ship.c index c087a75d..bbd77420 100644 --- a/src/lib/subs/ship.c +++ b/src/lib/subs/ship.c @@ -55,7 +55,7 @@ shp_postread(int n, s_char *ptr) if (sp->shp_uid != n) { logerror("shp_postread: Error - %d != %d, zeroing.\n", sp->shp_uid, n); - bzero(ptr, sizeof(struct shpstr)); + memset(sp, 0, sizeof(struct shpstr)); } if (opt_MOB_ACCESS) diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 635696a7..da0e25aa 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -104,12 +104,11 @@ shp_sel(struct nstr_item *ni, struct emp_qelem *list) */ ship.shp_mission = 0; ship.shp_rflags = 0; - bzero(ship.shp_rpath, RET_LEN); + memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath)); putship(ship.shp_uid, &ship); mlp = (struct mlist *)malloc(sizeof(struct mlist)); mlp->mcp = mcp; - bcopy((s_char *)&ship, (s_char *)&mlp->ship, - sizeof(struct shpstr)); + mlp->ship = ship; mlp->mobil = (double)ship.shp_mobil; emp_insque(&mlp->queue, list); } @@ -190,8 +189,7 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp, *minmobp = mlp->mobil; if (mlp->mobil > *maxmobp) *maxmobp = mlp->mobil; - bcopy((s_char *)&ship, (s_char *)&mlp->ship, - sizeof(struct shpstr)); + mlp->ship = ship; } } @@ -1051,7 +1049,7 @@ shp_missdef(struct shpstr *sp, natid victim) mlp = (struct mlist *)malloc(sizeof(struct mlist)); mlp->mcp = &mchr[(int)sp->shp_type]; - bcopy((s_char *)sp, (s_char *)&mlp->ship, sizeof(struct shpstr)); + mlp->ship = *sp; mlp->mobil = (double)sp->shp_mobil; emp_insque(&mlp->queue, &list); sprintf(buf, "%s", prship(&mlp->ship)); diff --git a/src/lib/subs/supply.c b/src/lib/subs/supply.c index f79abf4a..b438a6a9 100644 --- a/src/lib/subs/supply.c +++ b/src/lib/subs/supply.c @@ -398,7 +398,7 @@ s_commod(int own, int x, int y, int type, int total_wanted, int hold; struct lndstr l2; - bcopy((s_char *)&land, (s_char *)&l2, sizeof(struct lndstr)); + l2 = land; hold = vec[type]; vec[type] = 0; putvec(VT_ITEM, vec, (s_char *)&land, EF_LAND); diff --git a/src/lib/subs/takeover.c b/src/lib/subs/takeover.c index 3a75716d..eb0f4998 100644 --- a/src/lib/subs/takeover.c +++ b/src/lib/subs/takeover.c @@ -69,7 +69,7 @@ takeover(register struct sctstr *sp, natid newown) extern int sect_mob_neg_factor; /* Wipe all the distribution info */ - bzero((s_char *)vec, sizeof(vec)); + memset(vec, 0, sizeof(vec)); putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR); putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR); if (sp->sct_own == 0) @@ -240,7 +240,7 @@ takeover_ship(register struct shpstr *sp, natid newown, int hostile) sp->shp_rflags = 0; /* Keep track of when this was taken over */ time(&sp->shp_access); - bzero(sp->shp_rpath, RET_LEN); + memset(sp->shp_rpath, 0, sizeof(sp->shp_rpath)); pp = &p; lp = &llp; /* Take over planes */ diff --git a/src/lib/update/finish.c b/src/lib/update/finish.c index 370272f9..5e555bba 100644 --- a/src/lib/update/finish.c +++ b/src/lib/update/finish.c @@ -103,8 +103,7 @@ finish_sects(int etu) } /* Wipe it clean */ - bzero((s_char *)g_distptrs, ((WORLD_X * WORLD_Y) * - sizeof(struct distinfo))); + memset(g_distptrs, 0, ((WORLD_X * WORLD_Y) * sizeof(struct distinfo))); logerror("delivering...\n"); /* Do deliveries */ @@ -233,7 +232,7 @@ assemble_dist_paths(struct distinfo *distptrs) cost */ infptr->excost = pathcost(sp, p, MOB_ROAD); #ifdef SAVE_FINISH_PATHS - bcopy(p, infptr->path, len); + memcpy(infptr->path, p, len); #else infptr->path = finish_path; #endif /* SAVE_FINISH_PATHS */ diff --git a/src/lib/update/land.c b/src/lib/update/land.c index 6805a32d..9db0d5cd 100644 --- a/src/lib/update/land.c +++ b/src/lib/update/land.c @@ -295,7 +295,7 @@ landrepair(register struct lndstr *land, int *vec, struct natstr *np, leftp = ((float)left / 100.0); - bzero((s_char *)mvec, sizeof(mvec)); + memset(mvec, 0, sizeof(mvec)); mvec[I_LCM] = lcm_needed = ldround((double)(lp->l_lcm * leftp), 1); mvec[I_HCM] = hcm_needed = ldround((double)(lp->l_hcm * leftp), 1); /* @@ -324,7 +324,7 @@ landrepair(register struct lndstr *land, int *vec, struct natstr *np, build = ldround((double)(buildp * 100.0), 1); - bzero((s_char *)mvec, sizeof(mvec)); + memset(mvec, 0, sizeof(mvec)); mvec[I_LCM] = lcm_needed = roundavg((double)(lp->l_lcm * buildp)); mvec[I_HCM] = hcm_needed = roundavg((double)(lp->l_hcm * buildp)); /* diff --git a/src/lib/update/main.c b/src/lib/update/main.c index e1354890..b1aa0c13 100644 --- a/src/lib/update/main.c +++ b/src/lib/update/main.c @@ -95,10 +95,10 @@ update_main(void *argv) * happiness, and printing out the state of the nation) */ logerror("production update (%d etus)", etu); - bzero((s_char *)pops, sizeof(pops)); - bzero((s_char *)air_money, sizeof(air_money)); - bzero((s_char *)sea_money, sizeof(sea_money)); - bzero((s_char *)lnd_money, sizeof(lnd_money)); + memset(pops, 0, sizeof(pops)); + 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)); for (n = 0; n < MAXNOC; n++) { money[n] = 0; @@ -116,7 +116,7 @@ update_main(void *argv) int y, z, sb = 0, sm = 0, pb = 0, pm = 0, lm = 0, lb = 0; long p_sect[SCT_MAXDEF + 1][2]; - bzero((s_char *)p_sect, sizeof(p_sect)); + memset(p_sect, 0, sizeof(p_sect)); mil_dbl_pay = 0; if ((np = getnatp(x)) == (struct natstr *)0) continue; diff --git a/src/lib/update/nat.c b/src/lib/update/nat.c index b40ad983..1b4f745f 100644 --- a/src/lib/update/nat.c +++ b/src/lib/update/nat.c @@ -196,8 +196,8 @@ prod_nat(int etu) if (ally_factor > 0.0) share_incr(res, tech); else { - bzero((s_char *)res, sizeof(res)); - bzero((s_char *)tech, sizeof(tech)); + memset(res, 0, sizeof(res)); + memset(tech, 0, sizeof(tech)); } for (n = 0; NULL != (np = getnatp(n)); n++) { if ((np->nat_stat & STAT_NORM) == 0) diff --git a/src/lib/update/nav_ship.c b/src/lib/update/nav_ship.c index 7b9aa1e0..61622bee 100644 --- a/src/lib/update/nav_ship.c +++ b/src/lib/update/nav_ship.c @@ -269,7 +269,7 @@ nav_ship(register struct shpstr *sp) emp_initque(&ship_list); mlp = (struct mlist *)malloc(sizeof(struct mlist)); mlp->mcp = mchr + sp->shp_type; - bcopy((s_char *)sp, (s_char *)&mlp->ship, sizeof(struct shpstr)); + mlp->ship = *sp; mlp->mobil = (double)sp->shp_mobil; emp_insque(&mlp->queue, &ship_list); diff --git a/src/lib/update/plague.c b/src/lib/update/plague.c index ac463759..1eafa652 100644 --- a/src/lib/update/plague.c +++ b/src/lib/update/plague.c @@ -63,7 +63,7 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu) if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0) return; if (getvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR) <= 0) - bzero((s_char *)cvec, sizeof(cvec)); + memset(cvec, 0, sizeof(cvec)); if (cvec[C_PSTAGE] == 0) { cvec[C_PSTAGE] = infect_people(np, vec, sp->sct_effic, diff --git a/src/lib/update/plane.c b/src/lib/update/plane.c index dd0fcac4..b016d2c9 100644 --- a/src/lib/update/plane.c +++ b/src/lib/update/plane.c @@ -203,7 +203,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem) left = delta; leftp = ((float)left / 100.0); - bzero((s_char *)mvec, sizeof(mvec)); + memset(mvec, 0, sizeof(mvec)); mvec[I_MILIT] = mil_needed = ldround((double)(plp->pl_crew * leftp), 1); mvec[I_LCM] = lcm_needed = @@ -227,7 +227,7 @@ prod_plane(int etus, int natnum, int *bp, int buildem) (float)plp->pl_hcm)); build = ldround((double)(buildp * 100.0), 1); - bzero((s_char *)mvec, sizeof(mvec)); + memset(mvec, 0, sizeof(mvec)); mvec[I_MILIT] = mil_needed = roundavg((double)(plp->pl_crew * buildp)); mvec[I_LCM] = lcm_needed = diff --git a/src/lib/update/prepare.c b/src/lib/update/prepare.c index 677b83c0..f8b05a39 100644 --- a/src/lib/update/prepare.c +++ b/src/lib/update/prepare.c @@ -62,7 +62,7 @@ prepare_sects(int etu, int *bp) struct natstr *np; int n, civ_tax, uw_tax, mil_pay; - bzero((s_char *)levels, sizeof(levels)); + memset(levels, 0, sizeof(levels)); /* Process all the fallout. */ if (opt_FALLOUT) { diff --git a/src/lib/update/sail.c b/src/lib/update/sail.c index 8d642d6e..0e6efe72 100644 --- a/src/lib/update/sail.c +++ b/src/lib/update/sail.c @@ -170,7 +170,7 @@ sail_find_fleet(struct fltheadstr **head, struct shpstr *sp) if (!fltp) { fltp = (struct fltheadstr *)malloc(sizeof(*fltp)); - bzero((s_char *)fltp, sizeof(*fltp)); + memset(fltp, 0, sizeof(*fltp)); /* Fix the links. */ fltp->next = (*head); @@ -195,7 +195,7 @@ sail_find_fleet(struct fltheadstr **head, struct shpstr *sp) } this = (struct fltelemstr *)malloc(sizeof(*this)); - bzero((s_char *)this, sizeof(*this)); + memset(this, 0, sizeof(*this)); this->num = sp->shp_uid; this->own = sp->shp_own; this->next = fltp->head; @@ -345,7 +345,7 @@ fltp_to_list(struct fltheadstr *fltp, struct emp_qelem *list) mlp = (struct mlist *)malloc(sizeof(struct mlist)); sp = getshipp(fe->num); mlp->mcp = mchr + sp->shp_type; - bcopy((s_char *)sp, (s_char *)&mlp->ship, sizeof(struct shpstr)); + mlp->ship = *sp; mlp->mobil = fe->mobil; emp_insque(&mlp->queue, list); } diff --git a/src/lib/update/ship.c b/src/lib/update/ship.c index 04596212..3a9f6de0 100644 --- a/src/lib/update/ship.c +++ b/src/lib/update/ship.c @@ -376,7 +376,7 @@ shiprepair(register struct shpstr *ship, int *vec, struct natstr *np, left = delta; leftp = ((float)left / 100.0); - bzero((s_char *)mvec, sizeof(mvec)); + memset(mvec, 0, sizeof(mvec)); mvec[I_LCM] = lcm_needed = ldround((double)(mp->m_lcm * leftp), 1); mvec[I_HCM] = hcm_needed = ldround((double)(mp->m_hcm * leftp), 1); @@ -390,7 +390,7 @@ shiprepair(register struct shpstr *ship, int *vec, struct natstr *np, buildp = MIN(buildp, ((float)mvec[I_HCM] / (float)mp->m_hcm)); build = ldround((double)(buildp * 100.0), 1); - bzero((s_char *)mvec, sizeof(mvec)); + memset(mvec, 0, sizeof(mvec)); mvec[I_LCM] = lcm_needed = roundavg((double)(mp->m_lcm * buildp)); mvec[I_HCM] = hcm_needed = roundavg((double)(mp->m_hcm * buildp)); diff --git a/src/util/files.c b/src/util/files.c index fc0fdf2b..b80e1967 100644 --- a/src/util/files.c +++ b/src/util/files.c @@ -129,7 +129,7 @@ main(int argc, char *argv[]) exit(1); } } - bzero((s_char *)&nat, sizeof(nat)); + memset (&nat, 0, sizeof(nat)); nat.ef_type = EF_NATION; if (nat.nat_cnam[0] == 0) strcpy(nat.nat_cnam, "POGO"); @@ -144,7 +144,7 @@ main(int argc, char *argv[]) nat.nat_priorities[x] = -1; putnat((&nat)); printf("All praise to %s!\n", nat.nat_cnam); - bzero((s_char *)&nat, sizeof(nat)); + memset (&nat, 0, sizeof(nat)); for (x = 0; x < SCT_MAXDEF + 8; x++) nat.nat_priorities[x] = -1; for (i = 1; i < MAXNOC; i++) { @@ -175,7 +175,7 @@ main(int argc, char *argv[]) chmod(teldir, 0770); /* create a zero-filled sector file */ - bzero((s_char *)&sct, sizeof(sct)); + memset(&sct, 0, sizeof(sct)); for (y = 0; y < WORLD_Y; y++) { for (x = 0; x < WORLD_X / 2; x++) { file_sct_init(x * 2 + (y & 01), y, (s_char *)&sct); diff --git a/src/util/ore.c b/src/util/ore.c index 0342286f..7a6d895b 100644 --- a/src/util/ore.c +++ b/src/util/ore.c @@ -366,7 +366,7 @@ s_char *restype; x2 = x1; y2 = y1; - bzero((s_char *)tried, sizeof(tried)); + memset(tried, 0, sizeof(tried)); numtried = 0; while ((sects[y2 * XPLATES + x2 / 2].sct_type == SCT_WATER) || (*