commit bd9f46c38a1ac33ff21e527432bb270971415b59
parent 011c9af71570ddbeeccadb6d8f1e9e90fbda4424
Author: Pollux <pollux@pollux.codes>
Date: Sat, 18 Jan 2025 21:48:02 -0600
fix: cli options used before parsed
Signed-off-by: Pollux <pollux@pollux.codes>
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/runcl.c b/src/runcl.c
@@ -35,8 +35,8 @@ int main(int argc, char **argv) {
opterr = 0;
- int data_size_out = sizeof(float) * img_width * img_height * 3;
- float *data_out = (float *)malloc(data_size_out);
+ int data_size_out;
+ float *data_out;
cl_platform_id platform_id = NULL;
@@ -55,7 +55,7 @@ int main(int argc, char **argv) {
FILE *fp;
cl_uint platform_count = 256;
- cl_platform_id *platforms = malloc(platform_count * sizeof(cl_platform_id));
+ cl_platform_id *platforms;
cl_int err;
@@ -67,7 +67,6 @@ int main(int argc, char **argv) {
png_structp png_ptr;
png_infop info_ptr;
png_bytep row;
- row = (png_bytep)malloc(3 * img_width * sizeof(png_byte));
while ((c = getopt(argc, argv, "p:w:h:Hv")) != -1) {
switch (c) {
@@ -94,6 +93,12 @@ int main(int argc, char **argv) {
}
}
+ data_size_out = sizeof(float) * img_width * img_height * 3;
+ data_out = (float *)malloc(data_size_out);
+
+ platforms = malloc(platform_count * sizeof(cl_platform_id));
+ row = (png_bytep)malloc(3 * img_width * sizeof(png_byte));
+
if (argc < optind + 2) {
fprintf(stderr, "Error parsing command-line arguments...\n");
return 1;