strdup/dupstr (trunk only)
Add dupstr() as a substitute for strdup() so that out-of-memory
handling will be consistent with the rest of nethack, and make it aware
of nethack's heap logging. It's treated like alloc() so that its caller
can be logged for NH_HEAPLOG.
I put it into use in a few places, but there are lots more candidates
besides the existing calls to strdup() that should be replaced.
This commit is contained in:
6
src/do.c
6
src/do.c
@@ -1444,9 +1444,9 @@ const char *pre_msg, *post_msg;
|
||||
assign_level(&u.utolev, tolev);
|
||||
|
||||
if (pre_msg)
|
||||
dfr_pre_msg = strcpy((char *)alloc(strlen(pre_msg) + 1), pre_msg);
|
||||
dfr_pre_msg = dupstr(pre_msg);
|
||||
if (post_msg)
|
||||
dfr_post_msg = strcpy((char *)alloc(strlen(post_msg)+1), post_msg);
|
||||
dfr_post_msg = dupstr(post_msg);
|
||||
}
|
||||
|
||||
/* handle something like portal ejection */
|
||||
@@ -1572,7 +1572,7 @@ struct obj *corpse;
|
||||
void
|
||||
revive_mon(arg, timeout)
|
||||
anything *arg;
|
||||
long timeout;
|
||||
long timeout UNUSED;
|
||||
{
|
||||
struct obj *body = arg->a_obj;
|
||||
struct permonst *mptr = &mons[body->corpsenm];
|
||||
|
||||
Reference in New Issue
Block a user