aboutsummaryrefslogtreecommitdiff
path: root/maketab.c
diff options
context:
space:
mode:
authorzoulasc <zoulasc@users.noreply.github.com>2019-10-24 09:40:15 -0400
committerArnold Robbins <arnold@skeeve.com>2019-10-24 09:40:15 -0400
commit6589208eaf7e7da73a5a3fe8420c37c970206edc (patch)
tree79b28afbc59b47b32967ebcf004faecec437d9ae /maketab.c
parent1633ba1c8830ccd6592f27c732980a60579d81f2 (diff)
downloadone-true-awk-6589208eaf7e7da73a5a3fe8420c37c970206edc.tar.gz
More cleanups: (#53)
- sprinkle const - add a macro (setptr) that cheats const to temporarily NUL terminate strings remove casts from allocations - use strdup instead of strlen+strcpy - use x = malloc(sizeof(*x)) instead of x = malloc(sizeof(type of *x))) - add -Wcast-qual (and casts through unitptr_t in the two macros we cheat (xfree, setptr)).
Diffstat (limited to 'maketab.c')
-rw-r--r--maketab.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/maketab.c b/maketab.c
index 9faed84..cd15b98 100644
--- a/maketab.c
+++ b/maketab.c
@@ -145,8 +145,7 @@ int main(int argc, char *argv[])
/* fprintf(stderr, "maketab funny token %d %s ignored\n", tok, buf); */
continue;
}
- names[tok-FIRSTTOKEN] = (char *) malloc(strlen(name)+1);
- strcpy(names[tok-FIRSTTOKEN], name);
+ names[tok-FIRSTTOKEN] = strdup(name);
printf("\t(char *) \"%s\",\t/* %d */\n", name, tok);
i++;
}