Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] [OMPI svn] svn:open-mpi r28029 - trunk/opal/class
From: George Bosilca (bosilca_at_[hidden])
Date: 2013-02-04 17:13:42


Ralph,

There are valid reasons why we decided not to add such macros.

Adding elements to a list do not increase the element ref count.
Similarly, removing an element from a list does not decrease its
refcount either. Thus, there is no obvious link between the refcount
of the elements in a list and the list itself. As a result, we can not
make the assumption that decreasing the refcount by one is correct,
and this even when we plan to get rid of one of our lists.

In addition, the list can contain elements that have been
OBJ_CONSTRUCT in which case this macro will lead to unexpected
behaviors.

  George.

On Mon, Feb 4, 2013 at 2:42 PM, <svn-commit-mailer_at_[hidden]> wrote:
> Author: rhc (Ralph Castain)
> Date: 2013-02-04 14:42:57 EST (Mon, 04 Feb 2013)
> New Revision: 28029
> URL: https://svn.open-mpi.org/trac/ompi/changeset/28029
>
> Log:
> The opal_list_t destructor doesn't release the items on the list prior to destructing or releasing it. Provide two convenience macros for doing so.
>
> Text files modified:
> trunk/opal/class/opal_list.h | 26 ++++++++++++++++++++++++++
> 1 files changed, 26 insertions(+), 0 deletions(-)
>
> Modified: trunk/opal/class/opal_list.h
> ==============================================================================
> --- trunk/opal/class/opal_list.h Mon Feb 4 12:36:55 2013 (r28028)
> +++ trunk/opal/class/opal_list.h 2013-02-04 14:42:57 EST (Mon, 04 Feb 2013) (r28029)
> @@ -160,6 +160,32 @@
> */
> typedef struct opal_list_t opal_list_t;
>
> +/** Cleanly destruct a list
> + *
> + * The opal_list_t destructor doesn't release the items on the
> + * list - so provide two convenience macros that do so and then
> + * destruct/release the list object itself
> + *
> + * @param[in] list List to destruct or release
> + */
> +#define OPAL_LIST_DESTRUCT(list) \
> + do { \
> + opal_list_item_t *it; \
> + while (NULL != (it = opal_list_remove_first(list))) { \
> + OBJ_RELEASE(it); \
> + } \
> + OBJ_DESTRUCT(list); \
> + } while(0);
> +
> +#define OPAL_LIST_RELEASE(list) \
> + do { \
> + opal_list_item_t *it; \
> + while (NULL != (it = opal_list_remove_first(list))) { \
> + OBJ_RELEASE(it); \
> + } \
> + OBJ_RELEASE(list); \
> + } while(0);
> +
>
> /**
> * Loop over a list.
> _______________________________________________
> svn mailing list
> svn_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/svn