Results 1 to 2 of 2

Thread: NULL or !NULL

  1. #1

    NULL or !NULL

    Hi forum,

    Check the following code

    Code :
    cl_mem buffer;

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

    Code :
    cl_mem buffer = NULL;

    If i release a memory object as follows:

    Code :

    will the buffer again initialized to NULL ?


  2. #2
    Junior Member
    Join Date
    May 2011
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean