Ignore:
Timestamp:
2011-03-30T13:10:24Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4ae90f9
Parents:
6e50466 (diff), d6b81941 (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_char_map.h

    r6e50466 rad7a6c9  
    4747#define GENERIC_CHAR_MAP_MAGIC_VALUE    0x12345622
    4848
     49/** Generic destructor function pointer. */
     50#define DTOR_T(identifier) \
     51        void (*identifier)(const void *)
     52
    4953/** Character string to generic type map declaration.
    5054 *  @param[in] name     Name of the map.
     
    6266        }; \
    6367        \
    64         int name##_add(name##_t *, const char *, const size_t, type *); \
     68        int name##_add(name##_t *, const uint8_t *, const size_t, type *); \
    6569        int name##_count(name##_t *); \
    66         void name##_destroy(name##_t *); \
    67         void name##_exclude(name##_t *, const char *, const size_t); \
    68         type *name##_find(name##_t *, const char *, const size_t); \
     70        void name##_destroy(name##_t *, DTOR_T()); \
     71        void name##_exclude(name##_t *, const uint8_t *, const size_t, DTOR_T()); \
     72        type *name##_find(name##_t *, const uint8_t *, const size_t); \
    6973        int name##_initialize(name##_t *); \
    7074        int name##_is_valid(name##_t *);
     
    7478 * Should follow declaration with the same parameters.
    7579 *
    76  * @param[in] name      Name of the map.
    77  * @param[in] type      Inner object type.
     80 * @param[in] name Name of the map.
     81 * @param[in] type Inner object type.
     82 *
    7883 */
    7984#define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \
    8085        GENERIC_FIELD_IMPLEMENT(name##_items, type) \
    8186        \
    82         int name##_add(name##_t *map, const char *name, const size_t length, \
     87        int name##_add(name##_t *map, const uint8_t *name, const size_t length, \
    8388             type *value) \
    8489        { \
    85                 int rc; \
    8690                int index; \
    8791                if (!name##_is_valid(map)) \
     
    9094                if (index < 0) \
    9195                        return index; \
    92                 rc = char_map_add(&map->names, name, length, index); \
    93                 if (rc != EOK) { \
    94                         name##_items_exclude_index(&map->values, index); \
    95                         return rc; \
    96                 } \
    97                 return EOK; \
     96                return char_map_add(&map->names, name, length, index); \
    9897        } \
    9998        \
     
    104103        } \
    105104        \
    106         void name##_destroy(name##_t *map) \
     105        void name##_destroy(name##_t *map, DTOR_T(dtor)) \
    107106        { \
    108107                if (name##_is_valid(map)) { \
    109108                        char_map_destroy(&map->names); \
    110                         name##_items_destroy(&map->values); \
     109                        name##_items_destroy(&map->values, dtor); \
    111110                } \
    112111        } \
    113112        \
    114         void name##_exclude(name##_t *map, const char *name, \
    115             const size_t length) \
     113        void name##_exclude(name##_t *map, const uint8_t *name, \
     114            const size_t length, DTOR_T(dtor)) \
    116115        { \
    117116                if (name##_is_valid(map)) { \
     
    120119                        if (index != CHAR_MAP_NULL) \
    121120                                name##_items_exclude_index(&map->values, \
    122                                      index); \
     121                                     index, dtor); \
    123122                } \
    124123        } \
    125124        \
    126         type *name##_find(name##_t *map, const char *name, \
     125        type *name##_find(name##_t *map, const uint8_t *name, \
    127126            const size_t length) \
    128127        { \
Note: See TracChangeset for help on using the changeset viewer.