Hi forum,

Check the following code

cl_mem buffer;

Is the above variable automatically initialized to NULL unless i do the following :

cl_mem buffer = NULL;

If i release a memory object as follows:


will the buffer again initialized to NULL ?


Usually in C code you can’t make those sorts of assumption and that is the case here for the same reason. buffer will not be initialized and the buffer variable will not be reinitialized after a release. You can think of this in the same way as:
int* a; // not initialized
a = malloc(…); // initialized (on either success or failure if malloc will return 0 on failure)
free(a); // uses a to find memory to free, but does not update a itself
a = NULL; // reinitializes a to a meaningful value