<Someone> noticed the leftover zeromextra, this removes it.
Using memset() on a possibly failed mextra allocation was inapprorpriate,
so replace the newmextra() macro with a function.
Prevent a crash in christen_monst() if mextra was not initialized.
E struct monst *FDECL(clone_mon, (struct monst *,XCHAR_P,XCHAR_P));
E int FDECL(monhp_per_lvl, (struct monst *));
E void FDECL(newmonhp, (struct monst *,int));
+E struct mextra *NDECL(newmextra);
E struct monst *FDECL(makemon, (struct permonst *,int,int,int));
E boolean FDECL(create_critters, (int,struct permonst *));
E struct permonst *NDECL(rndmonst);
struct edog *edog;
};
-#define newmextra() \
- (struct mextra *) memset((genericptr_t)alloc(sizeof(struct mextra)), \
- 0, sizeof(struct mextra))
-
#define MNAME(mon) ((mon)->mextra->mname)
#define EGD(mon) ((mon)->mextra->egd)
#define EPRI(mon) ((mon)->mextra->epri)
return mtmp;
}
if (has_name(mtmp)) free((genericptr_t)MNAME(mtmp));
+ if (!mtmp->mextra) mtmp->mextra = newmextra();
MNAME(mtmp) = (char *)alloc(lth);
if (lth) Strcpy(MNAME(mtmp), name);
#endif
STATIC_VAR NEARDATA struct monst zeromonst;
-STATIC_VAR NEARDATA struct mextra zeromextra;
/* this assumes that a human quest leader or nemesis is an archetype
of the corresponding role; that isn't so for some roles (tourist
}
}
+struct mextra *
+newmextra()
+{
+ struct mextra *mextra;
+ mextra = (struct mextra *)alloc(sizeof(struct mextra));
+ if (mextra)
+ (void) memset((genericptr_t)mextra, 0, sizeof(struct mextra));
+ return mextra;
+}
+
/*
* called with [x,y] = coordinates;
* [0,0] means anyplace