diff options
author | David Phillips <david@sighup.nz> | 2017-02-25 19:29:15 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2017-02-25 19:29:15 +1300 |
commit | 2ccd529d87a372f730a463646c9ccd7a82c4c022 (patch) | |
tree | 2b6b99b2f3ca97ab4e7b44e2f184fb1057f632e2 | |
parent | 29ca840a2ebf8ebed0bc098e01590b6c8936330a (diff) | |
download | fractal-gen-opencl-2ccd529d87a372f730a463646c9ccd7a82c4c022.tar.xz |
Better initialisation style, remove dead whitespace/indentation
-rw-r--r-- | trampoline.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/trampoline.c b/trampoline.c index ef1ef14..71f4fe4 100644 --- a/trampoline.c +++ b/trampoline.c @@ -120,7 +120,7 @@ int select_platform(const char *preferred_platform) int tramp_init(const char *preferred_platform) { - cl_int ret; + cl_int ret = 0; if (select_platform(preferred_platform)) { return 1; @@ -169,7 +169,7 @@ void tramp_destroy() clReleaseProgram(program); clReleaseCommandQueue(command_queue); clReleaseContext(context); - + if (devices) { free(devices); devices = NULL; @@ -180,12 +180,15 @@ int tramp_load_kernel(const char *filename) { cl_int ret = 0; size_t length = 0; - FILE *fin = fopen(filename, "r"); + FILE *fin = NULL; char *source = NULL; + + fin = fopen(filename, "r"); if (!fin) { perror("fopen"); return 1; } + source = slurp(fin, &length); if (!source) return 1; @@ -193,7 +196,6 @@ int tramp_load_kernel(const char *filename) fclose(fin); program = clCreateProgramWithSource(context, 1, (const char **)&source, &length, &ret); - if (ret != CL_SUCCESS) { fprintf(stderr, "Failed to create program from source code: %s ", get_cl_error_string(ret)); return 1; |