cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

bardia
Journeyman III

C++ Wrapper Release ?

Hi All,

I need to release a cl::Buffer object and reallocate with different size during program execution. I have to declare it global to be available in other files and functions. Since cl::Buffer has not any direct desstructor, is it safe to use its parent (Wrapper) destructor? In other words: mycl_Buf.~Wrapper();

If no, what is the safe method?


Thanks in Advance

Bardia 

0 Likes
1 Solution
kozmo
Adept I

You can just assign a new cl::Buffer with different size to your global one like so:

mycl_Buf = cl::Buffer(...);

Assign operator will take care of the rest.

View solution in original post

0 Likes
2 Replies
kozmo
Adept I

You can just assign a new cl::Buffer with different size to your global one like so:

mycl_Buf = cl::Buffer(...);

Assign operator will take care of the rest.

0 Likes
LeeHowes
Staff

Yes, it all reference counts. That's the biggest benefit over using the C API, I think. You can pass objects around and the retain/release behaviour is automatic. Never call the destructors directly unless you really know what you are doing because it may end up being called again on object destruction.