Skip to content

Commit b37461d

Browse files
committed
Declare a const char *[] to initialize from the string constants then
strdup to a char *[].
1 parent 3dce815 commit b37461d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hack.rip.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
extern char plname[];
88

9-
static char *rip[] = {
9+
static const char *const rip_const[] = {
1010
" ----------",
1111
" / \\",
1212
" / REST \\",
@@ -24,15 +24,17 @@ static char *rip[] = {
2424
0
2525
};
2626

27+
static char *rip[SIZE(rip_const)];
28+
2729
outrip(){
2830
register char **dp = rip;
2931
register char *dpx;
3032
char buf[BUFSZ];
3133
register x,y;
3234

3335
/* The rip strings are expected to be writable so strdup them. */
34-
for (int i = 0; rip[i]; i++) {
35-
rip[i] = strdup(rip[i]);
36+
for (int i = 0; rip_const[i]; i++) {
37+
rip[i] = strdup(rip_const[i]);
3638
}
3739
cls();
3840
(void) strcpy(buf, plname);

0 commit comments

Comments
 (0)