Ignore:
Timestamp:
2011-04-07T21:38:17Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
033cbf82
Parents:
3acb285 (diff), ccca251 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/adt/generic_field.h

    r3acb285 r8436590  
    4646#define GENERIC_FIELD_MAGIC_VALUE               0x55667788
    4747
     48/** Generic destructor function pointer. */
     49#define DTOR_T(identifier) \
     50        void (*identifier)(const void *)
     51
    4852/** Generic type field declaration.
    4953 *
     
    6367        int name##_add(name##_t *, type *); \
    6468        int name##_count(name##_t *); \
    65         void name##_destroy(name##_t *); \
    66         void name##_exclude_index(name##_t *, int); \
     69        void name##_destroy(name##_t *, DTOR_T()); \
     70        void name##_exclude_index(name##_t *, int, DTOR_T()); \
    6771        type **name##_get_field(name##_t *); \
    6872        type *name##_get_index(name##_t *, int); \
     
    103107        } \
    104108        \
    105         void name##_destroy(name##_t *field) \
     109        void name##_destroy(name##_t *field, DTOR_T(dtor)) \
    106110        { \
    107111                if (name##_is_valid(field)) { \
    108112                        int index; \
    109113                        field->magic = 0; \
    110                         for (index = 0; index < field->next; index++) { \
    111                                 if (field->items[index]) \
    112                                         free(field->items[index]); \
     114                        if (dtor) { \
     115                                for (index = 0; index < field->next; index++) { \
     116                                        if (field->items[index]) \
     117                                                dtor(field->items[index]); \
     118                                } \
    113119                        } \
    114120                        free(field->items); \
     
    116122        } \
    117123         \
    118         void name##_exclude_index(name##_t *field, int index) \
     124        void name##_exclude_index(name##_t *field, int index, DTOR_T(dtor)) \
    119125        { \
    120126                if (name##_is_valid(field) && (index >= 0) && \
    121127                    (index < field->next) && (field->items[index])) { \
    122                         free(field->items[index]); \
     128                        if (dtor) \
     129                                dtor(field->items[index]); \
    123130                        field->items[index] = NULL; \
    124131                } \
Note: See TracChangeset for help on using the changeset viewer.