[Beignet] [PATCH] Fix event memory leak.
Yang Rong
rong.r.yang at intel.com
Sun Jun 15 19:59:36 PDT 2014
Rlease old event when old event is a valid event.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
src/cl_api.c | 5 ++++-
src/cl_utils.h | 3 +++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/cl_api.c b/src/cl_api.c
index c8d3cee..4288fd1 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -79,8 +79,11 @@ handle_events(cl_command_queue queue, cl_int num, const cl_event *wait_list,
cl_event_get_timestamp(e, CL_PROFILING_COMMAND_QUEUED);
}
- if(event != NULL)
+ if(event != NULL) {
+ if(IS_EVENT(*event))
+ cl_event_delete(*event);
*event = e;
+ }
if(status == CL_ENQUEUE_EXECUTE_DEFER) {
cl_event_new_enqueue_callback(e, data, num, wait_list);
}
diff --git a/src/cl_utils.h b/src/cl_utils.h
index fa900a7..f2cd8a4 100644
--- a/src/cl_utils.h
+++ b/src/cl_utils.h
@@ -149,6 +149,9 @@ do { \
struct _cl_mem_image *IMAGE; \
IMAGE = cl_mem_image(MEM); \
+#define IS_EVENT(EVENT) \
+ ((EVENT) && (EVENT)->magic == CL_MAGIC_EVENT_HEADER)
+
#define CHECK_EVENT(EVENT) \
do { \
if (UNLIKELY(EVENT == NULL)) { \
--
1.9.1
More information about the Beignet
mailing list