]> granicus.if.org Git - nethack/commitdiff
more dupstr (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 10 Mar 2012 02:49:08 +0000 (02:49 +0000)
committernethack.rankin <nethack.rankin>
Sat, 10 Mar 2012 02:49:08 +0000 (02:49 +0000)
src/files.c
src/mkobj.c
src/mon.c
src/region.c
src/rip.c
src/sounds.c

index 36631d818bf1b897205bf9e64bc113b15b8020b5..c899f259ede8d75f5e5cec8e8c0ad6ca3c96e458 100644 (file)
@@ -2363,7 +2363,7 @@ int               src;
 #endif
 #ifdef USER_SOUNDS
        } else if (match_varname(buf, "SOUNDDIR", 8)) {
-               sounddir = (char *)dupstr(bufp);
+               sounddir = dupstr(bufp);
        } else if (match_varname(buf, "SOUND", 5)) {
                add_sound_mapping(bufp);
 #endif
@@ -2372,15 +2372,15 @@ int             src;
        } else if (match_varname(buf, "QT_TILEWIDTH", 12)) {
                extern char *qt_tilewidth;
                if (qt_tilewidth == NULL)       
-                       qt_tilewidth=(char *)dupstr(bufp);
+                       qt_tilewidth = dupstr(bufp);
        } else if (match_varname(buf, "QT_TILEHEIGHT", 13)) {
                extern char *qt_tileheight;
                if (qt_tileheight == NULL)      
-                       qt_tileheight=(char *)dupstr(bufp);
+                       qt_tileheight = dupstr(bufp);
        } else if (match_varname(buf, "QT_FONTSIZE", 11)) {
                extern char *qt_fontsize;
                if (qt_fontsize == NULL)
-                       qt_fontsize=(char *)dupstr(bufp);
+                       qt_fontsize = dupstr(bufp);
        } else if (match_varname(buf, "QT_COMPACT", 10)) {
                extern int qt_compact_mode;
                qt_compact_mode = atoi(bufp);
index ef35d48693027384cce2d443882a81c99ac1612f..01a67f8f718e405b9d572b503cdcfaf12a1f215a 100644 (file)
@@ -172,12 +172,9 @@ new_omailcmd(otmp, response_cmd)
 struct obj *otmp;
 const char *response_cmd;
 {
-       unsigned lth = strlen(response_cmd) + 1;
-
        if (!otmp->oextra) otmp->oextra = newoextra();
        if (OMAILCMD(otmp)) free_omailcmd(otmp);
-       OMAILCMD(otmp) = (char *)alloc(lth);
-       Strcpy(OMAILCMD(otmp), response_cmd);
+       OMAILCMD(otmp) = dupstr(response_cmd);
 }
 
 void
index 43b143a843522fbde584dba3e661ff38292bc284..aff3ee4e21b71398c46ab644d223ed363a235e99 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1383,11 +1383,8 @@ struct monst *mtmp2, *mtmp1;
 
        if (!mtmp2->mextra) mtmp2->mextra = newmextra();
        if (MNAME(mtmp1)) {
-               int lth = strlen(MNAME(mtmp1)) + 1;
-               if (lth) {
-                       new_mname(mtmp2, lth);
-                       Strcpy(MNAME(mtmp2), MNAME(mtmp1));
-               }
+               new_mname(mtmp2, (int)strlen(MNAME(mtmp1)) + 1);
+               Strcpy(MNAME(mtmp2), MNAME(mtmp1));
        }
        if (EGD(mtmp1)) {
                if (!EGD(mtmp2)) newegd(mtmp2);
index e89822141dede0a9e44272c84035e2bb98ae5495..c3432291d29e12f50dfa09025b18ddce674fb818 100644 (file)
@@ -796,14 +796,10 @@ const char *msg_leave;
     NhRect tmprect;
     NhRegion *reg = create_region((NhRect *) 0, 0);
 
-    if (msg_enter) {
-       reg->enter_msg = (const char *) alloc(strlen(msg_enter) + 1);
-       Strcpy(reg->enter_msg, msg_enter);
-    }
-    if (msg_leave) {
-       reg->leave_msg = (const char *) alloc(strlen(msg_leave) + 1);
-       Strcpy(reg->leave_msg, msg_leave);
-    }
+    if (msg_enter)
+       reg->enter_msg = dupstr(msg_enter);
+    if (msg_leave)
+       reg->leave_msg = dupstr(msg_leave);
     tmprect.lx = x;
     tmprect.ly = y;
     tmprect.hx = x + w;
index 1e39b2377301e2184cc7cd9f364f8358d28960c3..85d0c4016b21cdc8265324d9e2dce02ae37ff8a9 100644 (file)
--- a/src/rip.c
+++ b/src/rip.c
@@ -96,10 +96,8 @@ time_t when;
        int line;
 
        rip = dp = (char **) alloc(sizeof(rip_txt));
-       for (x = 0; rip_txt[x]; x++) {
-               dp[x] = (char *) alloc((unsigned int)(strlen(rip_txt[x]) + 1));
-               Strcpy(dp[x], rip_txt[x]);
-       }
+       for (x = 0; rip_txt[x]; ++x)
+           dp[x] = dupstr(rip_txt[x]);
        dp[x] = (char *)0;
 
        /* Put name on stone */
index e7d78b16a39abde08edf34a333d91455d88647eb..eaac43337819a8482e4ec03dab7c661cf8950eae 100644 (file)
@@ -1098,8 +1098,7 @@ const char *mapping;
                new_map->regex.allocated = 0;
                new_map->regex.regs_allocated = REGS_FIXED;
 #else
-               new_map->pattern = (char *)alloc(strlen(text) + 1);
-               Strcpy(new_map->pattern, text);
+               new_map->pattern = dupstr(text);
 #endif
                new_map->filename = dupstr(filespec);
                new_map->volume = volume;