diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-09-01 14:30:01 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-09-01 14:30:01 +0200 |
commit | b402147109bb3f763381e2c0adba875916a7818c (patch) | |
tree | 825111cf9b11e6e990599f9774230ade57f41ef0 | |
parent | e9e5b4039b887b077f862818ee3508603e965952 (diff) | |
download | redo-c-b402147109bb3f763381e2c0adba875916a7818c.tar.gz redo-c-b402147109bb3f763381e2c0adba875916a7818c.tar.xz redo-c-b402147109bb3f763381e2c0adba875916a7818c.zip |
drop asprintf
-rw-r--r-- | redo.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/redo.c b/redo.c index f09b7c4..b4d354f 100644 --- a/redo.c +++ b/redo.c @@ -337,6 +337,12 @@ targetchdir(char *target) { } } +static char * targetdep(char *target) { + static char dep[1024]; + snprintf(dep, sizeof dep, ".%s.dep", target); + return dep; +} + static int check_deps(char *target) { @@ -352,7 +358,7 @@ check_deps(char *target) if (access(target, F_OK) != 0) return 0; - asprintf(&depfile, ".%s.dep", target); + depfile = targetdep(target); f = fopen(depfile, "r"); if (!f) return 0; @@ -445,9 +451,6 @@ run_script(char *target, int implicit) char *orig_target = target; target = targetchdir(target); - char *depfile; - asprintf(&depfile, ".%s.dep", target); - char temp_depfile[] = ".dep.XXXXXX"; int old_dep_fd = dep_fd; dep_fd = mkstemp(temp_depfile); @@ -670,11 +673,9 @@ redo_ifchange(int targetc, char *targetv[]) remove(job->temp_depfile); remove(job->temp_target); } else { - char *depfile; - char *target = targetchdir(job->target); + char *depfile = targetdep(target); - asprintf(&depfile, ".%s.dep", target); printf("renamed %s to %s.\n", job->temp_depfile, depfile); rename(job->temp_depfile, depfile); |