opencl: some minor fixes

- fix potential memleak
- make code more portable
- get rid of strtok
- fix some issues when compiling without opencl