more dupstr (trunk only)

This commit is contained in:
nethack.rankin
2012-03-10 02:49:08 +00:00
parent 78127038a0
commit d3c59c9e84
6 changed files with 14 additions and 27 deletions
+4 -4
View File
@@ -2363,7 +2363,7 @@ int src;
#endif #endif
#ifdef USER_SOUNDS #ifdef USER_SOUNDS
} else if (match_varname(buf, "SOUNDDIR", 8)) { } else if (match_varname(buf, "SOUNDDIR", 8)) {
sounddir = (char *)dupstr(bufp); sounddir = dupstr(bufp);
} else if (match_varname(buf, "SOUND", 5)) { } else if (match_varname(buf, "SOUND", 5)) {
add_sound_mapping(bufp); add_sound_mapping(bufp);
#endif #endif
@@ -2372,15 +2372,15 @@ int src;
} else if (match_varname(buf, "QT_TILEWIDTH", 12)) { } else if (match_varname(buf, "QT_TILEWIDTH", 12)) {
extern char *qt_tilewidth; extern char *qt_tilewidth;
if (qt_tilewidth == NULL) if (qt_tilewidth == NULL)
qt_tilewidth=(char *)dupstr(bufp); qt_tilewidth = dupstr(bufp);
} else if (match_varname(buf, "QT_TILEHEIGHT", 13)) { } else if (match_varname(buf, "QT_TILEHEIGHT", 13)) {
extern char *qt_tileheight; extern char *qt_tileheight;
if (qt_tileheight == NULL) if (qt_tileheight == NULL)
qt_tileheight=(char *)dupstr(bufp); qt_tileheight = dupstr(bufp);
} else if (match_varname(buf, "QT_FONTSIZE", 11)) { } else if (match_varname(buf, "QT_FONTSIZE", 11)) {
extern char *qt_fontsize; extern char *qt_fontsize;
if (qt_fontsize == NULL) if (qt_fontsize == NULL)
qt_fontsize=(char *)dupstr(bufp); qt_fontsize = dupstr(bufp);
} else if (match_varname(buf, "QT_COMPACT", 10)) { } else if (match_varname(buf, "QT_COMPACT", 10)) {
extern int qt_compact_mode; extern int qt_compact_mode;
qt_compact_mode = atoi(bufp); qt_compact_mode = atoi(bufp);
+1 -4
View File
@@ -172,12 +172,9 @@ new_omailcmd(otmp, response_cmd)
struct obj *otmp; struct obj *otmp;
const char *response_cmd; const char *response_cmd;
{ {
unsigned lth = strlen(response_cmd) + 1;
if (!otmp->oextra) otmp->oextra = newoextra(); if (!otmp->oextra) otmp->oextra = newoextra();
if (OMAILCMD(otmp)) free_omailcmd(otmp); if (OMAILCMD(otmp)) free_omailcmd(otmp);
OMAILCMD(otmp) = (char *)alloc(lth); OMAILCMD(otmp) = dupstr(response_cmd);
Strcpy(OMAILCMD(otmp), response_cmd);
} }
void void
+2 -5
View File
@@ -1383,11 +1383,8 @@ struct monst *mtmp2, *mtmp1;
if (!mtmp2->mextra) mtmp2->mextra = newmextra(); if (!mtmp2->mextra) mtmp2->mextra = newmextra();
if (MNAME(mtmp1)) { if (MNAME(mtmp1)) {
int lth = strlen(MNAME(mtmp1)) + 1; new_mname(mtmp2, (int)strlen(MNAME(mtmp1)) + 1);
if (lth) { Strcpy(MNAME(mtmp2), MNAME(mtmp1));
new_mname(mtmp2, lth);
Strcpy(MNAME(mtmp2), MNAME(mtmp1));
}
} }
if (EGD(mtmp1)) { if (EGD(mtmp1)) {
if (!EGD(mtmp2)) newegd(mtmp2); if (!EGD(mtmp2)) newegd(mtmp2);
+4 -8
View File
@@ -796,14 +796,10 @@ const char *msg_leave;
NhRect tmprect; NhRect tmprect;
NhRegion *reg = create_region((NhRect *) 0, 0); NhRegion *reg = create_region((NhRect *) 0, 0);
if (msg_enter) { if (msg_enter)
reg->enter_msg = (const char *) alloc(strlen(msg_enter) + 1); reg->enter_msg = dupstr(msg_enter);
Strcpy(reg->enter_msg, msg_enter); if (msg_leave)
} reg->leave_msg = dupstr(msg_leave);
if (msg_leave) {
reg->leave_msg = (const char *) alloc(strlen(msg_leave) + 1);
Strcpy(reg->leave_msg, msg_leave);
}
tmprect.lx = x; tmprect.lx = x;
tmprect.ly = y; tmprect.ly = y;
tmprect.hx = x + w; tmprect.hx = x + w;
+2 -4
View File
@@ -96,10 +96,8 @@ time_t when;
int line; int line;
rip = dp = (char **) alloc(sizeof(rip_txt)); rip = dp = (char **) alloc(sizeof(rip_txt));
for (x = 0; rip_txt[x]; x++) { for (x = 0; rip_txt[x]; ++x)
dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1)); dp[x] = dupstr(rip_txt[x]);
Strcpy(dp[x], rip_txt[x]);
}
dp[x] = (char *)0; dp[x] = (char *)0;
/* Put name on stone */ /* Put name on stone */
+1 -2
View File
@@ -1098,8 +1098,7 @@ const char *mapping;
new_map->regex.allocated = 0; new_map->regex.allocated = 0;
new_map->regex.regs_allocated = REGS_FIXED; new_map->regex.regs_allocated = REGS_FIXED;
#else #else
new_map->pattern = (char *)alloc(strlen(text) + 1); new_map->pattern = dupstr(text);
Strcpy(new_map->pattern, text);
#endif #endif
new_map->filename = dupstr(filespec); new_map->filename = dupstr(filespec);
new_map->volume = volume; new_map->volume = volume;