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)).
diff --git a/maketab.c b/maketab.c
index 9faed84..cd15b98 100644
--- a/maketab.c
+++ b/maketab.c
@@ -145,8 +145,7 @@
/* 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++;
}