declaration has been moved out of the '#else' below to avoid getting
a complaint from -Wmissing-prototypes when building with MONITOR_HEAP */
extern char *dupstr(const char *);
+/* same, but return strlen(string) */
+extern char *dupstr_n(const char *string, unsigned int *lenout);
/*
* MONITOR_HEAP is conditionally used for primitive memory leak debugging.
return strcpy((char *) alloc(strlen(string) + 1), string);
}
+/* similar for reasonable size strings, but return the length of the input as well */
+char *
+dupstr_n(const char *string, unsigned int *lenout)
+{
+ size_t len = strlen(string);
+ if(len >= LARGEST_INT)
+ panic("string too long");
+ *lenout = (unsigned int) len;
+ return strcpy((char *) alloc((unsigned)len + 1), string);
+}
+
/*alloc.c*/
} else if (newalign > u.ualign.record) {
u.ualign.record = newalign;
if (u.ualign.record > ALIGNLIM)
- u.ualign.record = ALIGNLIM;
+ u.ualign.record = (int)ALIGNLIM;
}
}
int i;
struct _cond_map {
unsigned long bm;
- unsigned long clratr;
+ unsigned int clratr;
} cond_maps[SIZE(conditions)];
(void) memset(cond_maps, 0,
atr &= ~HL_NONE;
if (clr != NO_COLOR || atr != HL_NONE) {
- unsigned long ca = clr | (atr << 8);
+ unsigned int ca = clr | (atr << 8);
boolean added_condmap = FALSE;
for (j = 0; j < SIZE(conditions); j++)
/* make sure we don't read into the next file */
if ((dp->size - dp->mark) < (size * quan))
- quan = (dp->size - dp->mark) / size;
+ quan = (int)((dp->size - dp->mark) / size);
if (quan == 0)
return 0;
dp->mark += nbytes;
dp->lib->fmark += nbytes;
- return nread;
+ return (int)nread;
}
static int
static boolean teleport_sink(void);
static void dosinkring(struct obj *);
static int drop(struct obj *);
-static int menudrop_split(struct obj *, int);
+static int menudrop_split(struct obj *, long);
static boolean engulfer_digests_food(struct obj *);
static int wipeoff(void);
static int menu_drop(int);
}
static int /* check callers */
-menudrop_split(struct obj *otmp, int cnt)
+menudrop_split(struct obj *otmp, long cnt)
{
if (cnt && cnt < otmp->quan) {
if (welded(otmp)) {
? herbivorous(g.youmonst.data)
: carnivorous(g.youmonst.data))
&& rn2(10)
- && ((rotted < 1) ? TRUE : !rn2(rotted+1)));
+ && ((rotted < 1) ? TRUE : !rn2((int)rotted+1)));
const char *pmxnam = food_xname(otmp, FALSE);
if (!strncmpi(pmxnam, "the ", 4))
struct _cnf_parser_state {
char *inbuf;
- size_t inbufsz;
+ unsigned inbufsz;
int rv;
char *ep;
char *buf;
|| has_dnstairs(sroom))
continue;
- rmno = (sroom - g.rooms) + ROOMOFFSET;
+ rmno = (int)(sroom - g.rooms) + ROOMOFFSET;
/* satisfied; make a swamp */
sroom->rtype = SWAMP;
if (ammo_and_launcher(otmp, mwep) && mwep->spe > 1)
multishot += (long) rounddiv(mwep->spe, 3);
/* Some randomness */
- multishot = (long) rnd((int) multishot);
+ multishot = rnd((int) multishot);
/* class bonus */
multishot += multishot_class_bonus(monsndx(mtmp->data), otmp, mwep);
if (!amorphous(g.youmonst.data) && !Passes_walls
&& !noncorporeal(g.youmonst.data) && !unsolid(g.youmonst.data)) {
You("are hit by %s!", doname(otmp2));
- dmg = dmgval(otmp2, &g.youmonst) * otmp2->quan;
+ dmg = (int) (dmgval(otmp2, &g.youmonst) * otmp2->quan);
if (uarmh && helmet_protects) {
if (is_metallic(uarmh)) {
pline("Fortunately, you are wearing a hard helmet.");
if (mtmp && !amorphous(mtmp->data) && !passes_walls(mtmp->data)
&& !noncorporeal(mtmp->data) && !unsolid(mtmp->data)) {
struct obj *helmet = which_armor(mtmp, W_ARMH);
- int mdmg;
+ long mdmg;
if (cansee(mtmp->mx, mtmp->my)) {
pline("%s is hit by %s!", Monnam(mtmp), doname(otmp2));
boolean
uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags)
{
- int rlen = 0, cmc = 0, filecmc = 0;
+ ssize_t rlen = 0;
+ int cmc = 0, filecmc = 0;
struct version_info vers_info;
boolean verbose = name ? TRUE : FALSE;
char indicator;