(bzero, bcopy): Obsolete BSDisms; remove. Remove some calls without
effect. Replace calls by struct assignment where possible. Replace clear buffer, copy string to buffer by strncpy(). Use assignment to clear when that's clearer. Replace overlapping copy through bounce buffer by memmove(). Replace rest by standard memset() and memcpy(). Also use sizeof() instead of literal array sizes for robustness, and instead of symbolic array sizes for clarity.
This commit is contained in:
parent
2910da23ea
commit
4ae9c417b3
79 changed files with 172 additions and 256 deletions
|
@ -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",
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue