Not really a bad exemple. It's a safety net, you release the object (which
doesn't means you free it, but simply that you don't need it anymore in
this particular context). You then set it to NULL to be sure you don't use
it anymore in that particular block of code. As Gilles said an harmless
overk
True - but to directly answer Adrian’s question:
Setting the buffer to NULL is not necessary and definitely a bad example.
> On Feb 12, 2015, at 3:01 AM, Gilles Gouaillardet
> wrote:
>
> Adrian,
>
> in the case of ompi/group/group_init.c, new_group = NULL is clearly an
> overkill,
> but ther
Adrian,
in the case of ompi/group/group_init.c, new_group = NULL is clearly an
overkill,
but there is nothing wrong with it :
it can only be 1 when OBJ_RELEASE is invoked
(and hence new_group is already NULL, so no need to NULLify it a second
time)
that being said some typing can also be saved by
I am not 100% sure I was understood correctly and I am also not sure I
understand the discussion I triggered.
Being not very familiar with the Open MPI code base I often look at
other places in the code for examples how something can/could be done.
Looking at different examples OBJ_RELEASE() I see
It would be good to know where you are seeing this - as was stated, the macro
reduces the ref count and will NULL the pointer if and only if the ref count
goes to zero. However, the code may set it to NULL for some other reason that
relates to the later use of that particular variable.
If not u
I was just curious as if I am calling
OBJ_RELEASE(buffer);
buffer = NULL;
on a buffer with an object count different to 1, the buffer is not free'd
but set to NULL. If I call it again the buffer is NULL and the original
buffer will not be free'd. Setting the buffer to NULL seems unnecessary.
I h
Adrian,
opal_obj_update does not fail or success, it returns the new
obj_reference_count.
can you point to one specific location in the code where you think it is
wrong ?
OBJ_RELEASE(buffer)
buffer = NULL;
could be written as
if (((opal_object_t *)buffer)->obj_reference_count == 1) {
OBJ_
At many places all over the code I see
OBJ_RELEASE(buffer)
buffer = NULL;
Looking at the definition of OBJ_RELEASE() this seems unnecessary and
wrong:
#define OBJ_RELEASE(object) \
do {