-/* $NetBSD: hack.engrave.c,v 1.7 2009/06/07 18:30:39 dholland Exp $ */
+/* $NetBSD: hack.engrave.c,v 1.14 2011/08/07 06:03:45 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.engrave.c,v 1.7 2009/06/07 18:30:39 dholland Exp $");
+__RCSID("$NetBSD: hack.engrave.c,v 1.14 2011/08/07 06:03:45 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
#define DUST 1
#define ENGRAVE 2
#define BURN 3
-} *head_engr;
+};
-struct engr *
+static struct engr *head_engr;
+
+static void del_engr(struct engr *);
+
+static struct engr *
engr_at(xchar x, xchar y)
{
struct engr *ep = head_engr;
{
struct engr *ep = engr_at(x, y);
char *t;
- int n;
+ size_t n;
+
if (ep && ep->engr_time <= moves) {
t = ep->engr_txt;
/*
wipe_engr_at(xchar x, xchar y, xchar cnt)
{
struct engr *ep = engr_at(x, y);
- int lth, pos;
+ int pos;
char ch;
+ size_t lth;
+
if (ep) {
if ((ep->engr_type != DUST) || Levitation) {
cnt = rn2(1 + 50 / (cnt + 1)) ? 0 : 1;
if ((ep = engr_at(x, y)) != NULL)
del_engr(ep);
- ep = (struct engr *)
- alloc((unsigned) (sizeof(struct engr) + strlen(s) + 1));
+ ep = alloc(sizeof(*ep) + strlen(s) + 1);
+
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_x = x;
if (uwep && uwep->cursed) {
/* Andreas Bormann */
pline("Since your weapon is welded to your hand,");
- pline("you use the %s.", aobjnam(uwep, (char *) 0));
+ pline("you use the %s.", aobjnam(uwep, NULL));
otmp = uwep;
} else {
if (!otmp)
}
if (oep)
len += strlen(oep->engr_txt) + spct;
- ep = (struct engr *) alloc((unsigned) (sizeof(struct engr) + len + 1));
+ ep = alloc(sizeof(*ep) + len + 1);
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_x = u.ux;
ep = ep->nxt_engr;
continue;
}
- bwrite(fd, (char *) &(ep->engr_lth), sizeof(ep->engr_lth));
- bwrite(fd, (char *) ep, sizeof(struct engr) + ep->engr_lth);
+ bwrite(fd, &(ep->engr_lth), sizeof(ep->engr_lth));
+ bwrite(fd, ep, sizeof(struct engr) + ep->engr_lth);
ep = ep->nxt_engr;
}
- bwrite(fd, (char *) nul, sizeof(unsigned));
+ bwrite(fd, nul, sizeof(unsigned));
head_engr = 0;
}
unsigned lth;
head_engr = 0;
while (1) {
- mread(fd, (char *) <h, sizeof(unsigned));
+ mread(fd, <h, sizeof(unsigned));
if (lth == 0)
return;
- ep = (struct engr *) alloc(sizeof(struct engr) + lth);
- mread(fd, (char *) ep, sizeof(struct engr) + lth);
+ ep = alloc(sizeof(*ep) + lth);
+ mread(fd, ep, sizeof(*ep) + lth);
ep->nxt_engr = head_engr;
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
head_engr = ep;
}
}
-void
+static void
del_engr(struct engr *ep)
{
struct engr *ept;
return;
fnd: ;
}
- free((char *) ep);
+ free(ep);
}