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.
authorrhc
Mon Feb 04 19:42:57 2013 +0000 (3 months ago)
changeset 213707fac70dfe1d2
parent 21368 7c5dbf69325d
child 21371 8613a1221ba0
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.
opal/class/opal_list.h
     1.1 --- a/opal/class/opal_list.h	Mon Feb 04 06:59:24 2013 +0000
     1.2 +++ b/opal/class/opal_list.h	Mon Feb 04 19:42:57 2013 +0000
     1.3 @@ -160,6 +160,32 @@
     1.4   */
     1.5  typedef struct opal_list_t opal_list_t;
     1.6  
     1.7 +/** Cleanly destruct a list
     1.8 + *
     1.9 + * The opal_list_t destructor doesn't release the items on the
    1.10 + * list - so provide two convenience macros that do so and then
    1.11 + * destruct/release the list object itself
    1.12 + *
    1.13 + * @param[in] list List to destruct or release
    1.14 + */
    1.15 +#define OPAL_LIST_DESTRUCT(list)                                \
    1.16 +    do {                                                        \
    1.17 +        opal_list_item_t *it;                                   \
    1.18 +        while (NULL != (it = opal_list_remove_first(list))) {   \
    1.19 +            OBJ_RELEASE(it);                                    \
    1.20 +        }                                                       \
    1.21 +        OBJ_DESTRUCT(list);                                     \
    1.22 +    } while(0);
    1.23 +
    1.24 +#define OPAL_LIST_RELEASE(list)                                 \
    1.25 +    do {                                                        \
    1.26 +        opal_list_item_t *it;                                   \
    1.27 +        while (NULL != (it = opal_list_remove_first(list))) {   \
    1.28 +            OBJ_RELEASE(it);                                    \
    1.29 +        }                                                       \
    1.30 +        OBJ_RELEASE(list);                                      \
    1.31 +    } while(0);
    1.32 +
    1.33  
    1.34  /**
    1.35   * Loop over a list.