void (CL_CALLBACK *pfn_notify) (cl_mem, void*),
void * user_data)
{
- NOT_IMPLEMENTED;
- return 0;
+ cl_int err = CL_SUCCESS;
+ CHECK_MEM(memobj);
+ INVALID_VALUE_IF (pfn_notify == 0);
+
+ cl_mem_dstr_cb *cb = (cl_mem_dstr_cb*)malloc(sizeof(cl_mem_dstr_cb));
+ if (!cb) {
+ err = CL_OUT_OF_HOST_MEMORY;
+ goto error;
+ }
+
+ memset(cb, 0, sizeof(cl_mem_dstr_cb));
+ cb->pfn_notify = pfn_notify;
+ cb->user_data = user_data;
+ cb->next = memobj->dstr_cb;
+ memobj->dstr_cb = cb;
+
+error:
+ return err;
}
cl_sampler
if (mem->mapped_ptr)
free(mem->mapped_ptr);
+ if (mem->dstr_cb) {
+ cl_mem_dstr_cb *cb = mem->dstr_cb;
+ while (mem->dstr_cb) {
+ cb = mem->dstr_cb;
+ cb->pfn_notify(mem, cb->user_data);
+ mem->dstr_cb = cb->next;
+ free(cb);
+ }
+ }
+
cl_free(mem);
}
size_t size;
}cl_mapped_ptr;
+typedef struct _cl_mem_dstr_cb {
+ struct _cl_mem_dstr_cb * next;
+ void (CL_CALLBACK *pfn_notify)(cl_mem memobj, void *user_data);
+ void *user_data;
+}cl_mem_dstr_cb;
+
/* Used for buffers and images */
struct _cl_mem {
DEFINE_ICD(dispatch)
cl_mapped_ptr* mapped_ptr;/* Store the mapped addresses and size by caller. */
int mapped_ptr_sz; /* The array size of mapped_ptr. */
int map_ref; /* The mapped count. */
+ cl_mem_dstr_cb *dstr_cb; /* The destroy callback. */
};
/* Query information about a memory object */