summaryrefslogtreecommitdiffstats
path: root/libhb/opencl.c
diff options
context:
space:
mode:
authorritsuka <[email protected]>2015-01-10 08:14:23 +0000
committerritsuka <[email protected]>2015-01-10 08:14:23 +0000
commit38523d35b04312ded4cc96f3dec73c4f36745884 (patch)
tree1ba3584936e8416bdf987613ec726aca2c8b3b68 /libhb/opencl.c
parent5b6cf99c90ca8518aabdf9065aa9b10cc76070f7 (diff)
Fix some leaks in OpenCL code. https://reviews.handbrake.fr/r/779/
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6715 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/opencl.c')
-rw-r--r--libhb/opencl.c57
1 files changed, 18 insertions, 39 deletions
diff --git a/libhb/opencl.c b/libhb/opencl.c
index 832f239c8..297d7d7a5 100644
--- a/libhb/opencl.c
+++ b/libhb/opencl.c
@@ -121,39 +121,7 @@ void hb_opencl_library_close(hb_opencl_library_t **_opencl)
{
HB_OCL_DLCLOSE(opencl->library);
}
- opencl->library = NULL;
-
-#define HB_OCL_UNLOAD(func) { opencl->func = NULL; }
- HB_OCL_UNLOAD(clBuildProgram);
- HB_OCL_UNLOAD(clCreateBuffer);
- HB_OCL_UNLOAD(clCreateCommandQueue);
- HB_OCL_UNLOAD(clCreateContextFromType);
- HB_OCL_UNLOAD(clCreateKernel);
- HB_OCL_UNLOAD(clCreateProgramWithBinary);
- HB_OCL_UNLOAD(clCreateProgramWithSource);
- HB_OCL_UNLOAD(clEnqueueCopyBuffer);
- HB_OCL_UNLOAD(clEnqueueMapBuffer);
- HB_OCL_UNLOAD(clEnqueueNDRangeKernel);
- HB_OCL_UNLOAD(clEnqueueReadBuffer);
- HB_OCL_UNLOAD(clEnqueueUnmapMemObject);
- HB_OCL_UNLOAD(clEnqueueWriteBuffer);
- HB_OCL_UNLOAD(clFlush);
- HB_OCL_UNLOAD(clGetCommandQueueInfo);
- HB_OCL_UNLOAD(clGetContextInfo);
- HB_OCL_UNLOAD(clGetDeviceIDs);
- HB_OCL_UNLOAD(clGetDeviceInfo);
- HB_OCL_UNLOAD(clGetPlatformIDs);
- HB_OCL_UNLOAD(clGetPlatformInfo);
- HB_OCL_UNLOAD(clGetProgramBuildInfo);
- HB_OCL_UNLOAD(clGetProgramInfo);
- HB_OCL_UNLOAD(clReleaseCommandQueue);
- HB_OCL_UNLOAD(clReleaseContext);
- HB_OCL_UNLOAD(clReleaseEvent);
- HB_OCL_UNLOAD(clReleaseKernel);
- HB_OCL_UNLOAD(clReleaseMemObject);
- HB_OCL_UNLOAD(clReleaseProgram);
- HB_OCL_UNLOAD(clSetKernelArg);
- HB_OCL_UNLOAD(clWaitForEvents);
+ free(opencl);
}
*_opencl = NULL;
}
@@ -283,9 +251,9 @@ static hb_list_t* hb_opencl_devices_list_get(hb_opencl_library_t *opencl,
return NULL;
}
- cl_device_id *device_ids;
- hb_opencl_device_t *device;
- cl_platform_id *platform_ids;
+ cl_device_id *device_ids = NULL;
+ hb_opencl_device_t *device = NULL;
+ cl_platform_id *platform_ids = NULL;
cl_uint i, j, num_platforms, num_devices;
if (opencl->clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS || !num_platforms)
@@ -326,11 +294,16 @@ static hb_list_t* hb_opencl_devices_list_get(hb_opencl_library_t *opencl,
}
}
}
- return list;
+
+ goto end;
fail:
hb_opencl_devices_list_close(&list);
- return NULL;
+
+end:
+ free(platform_ids);
+ free(device_ids);
+ return list;
}
int hb_opencl_available()
@@ -418,5 +391,11 @@ void hb_opencl_info_print()
}
end:
- hb_opencl_library_close(&opencl);
+ /*
+ * Close only the initialized part
+ */
+ if (opencl->library != NULL)
+ {
+ HB_OCL_DLCLOSE(opencl->library);
+ }
}