summaryrefslogtreecommitdiffstats
path: root/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-02-23 14:21:48 -0500
committerTavian Barnes <tavianator@gmail.com>2010-02-23 14:22:52 -0500
commitc76c0f017fa884c4b9a04ff7fa3b43d331c82d84 (patch)
tree96927779db344699486933474a48cbb51d61416c /dimension
parent6260a22ea7a9f08564483ea0beb76b6bdac34bb5 (diff)
downloaddimension-c76c0f017fa884c4b9a04ff7fa3b43d331c82d84.tar.xz
Determine nthreads in dmnsn_new_scene().
Diffstat (limited to 'dimension')
-rw-r--r--dimension/main.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/dimension/main.c b/dimension/main.c
index 00c0fdf..fa7f5a6 100644
--- a/dimension/main.c
+++ b/dimension/main.c
@@ -39,18 +39,18 @@ main(int argc, char **argv) {
/* Long-only option codes */
enum {
- DMNSN_NTHREADS = 256
+ DMNSN_OPT_THREADS = 256
};
static struct option long_options[] = {
- { "output", required_argument, NULL, 'o' },
- { "input", required_argument, NULL, 'i' },
- { "width", required_argument, NULL, 'w' },
- { "height", required_argument, NULL, 'h' },
- { "threads", required_argument, NULL, DMNSN_NTHREADS },
- { "tokenize", no_argument, &tokenize, 1 },
- { "parse", no_argument, &parse, 1 },
- { 0, 0, 0, 0 }
+ { "output", required_argument, NULL, 'o' },
+ { "input", required_argument, NULL, 'i' },
+ { "width", required_argument, NULL, 'w' },
+ { "height", required_argument, NULL, 'h' },
+ { "threads", required_argument, NULL, DMNSN_OPT_THREADS },
+ { "tokenize", no_argument, &tokenize, 1 },
+ { "parse", no_argument, &parse, 1 },
+ { 0, 0, 0, 0 }
};
int opt, opt_index;
@@ -105,12 +105,12 @@ main(int argc, char **argv) {
break;
}
- case DMNSN_NTHREADS:
+ case DMNSN_OPT_THREADS:
{
char *endptr;
nthreads = strtoul(optarg, &endptr, 10);
if (*endptr != '\0' || endptr == optarg) {
- fprintf(stderr, "Invalid argument to --nthreads!\n");
+ fprintf(stderr, "Invalid argument to --threads!\n");
return EXIT_FAILURE;
}
break;
@@ -216,7 +216,9 @@ main(int argc, char **argv) {
return EXIT_FAILURE;
}
- scene->nthreads = nthreads;
+ /* Set the new number of threads if --threads changed it */
+ if (nthreads)
+ scene->nthreads = nthreads;
/*
* Now we render the scene