Ignore:
Timestamp:
2010-11-25T13:42:50Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df8415
Parents:
a93d79a (diff), eb667613 (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

    ra93d79a r8fb1bf82  
    4040#include <unistd.h>
    4141#include <errno.h>
    42 #include <err.h>
    4342
    4443#include <adt/char_map.h>
     
    5655        \
    5756        typedef struct name name##_t; \
    58         typedef name##_t *name##_ref; \
    5957        \
    6058        struct  name { \
     
    6462        }; \
    6563        \
    66         int name##_add(name##_ref, const char *, const size_t, type *); \
    67         int name##_count(name##_ref); \
    68         void name##_destroy(name##_ref); \
    69         void name##_exclude(name##_ref, const char *, const size_t); \
    70         type *name##_find(name##_ref, const char *, const size_t); \
    71         int name##_initialize(name##_ref); \
    72         int name##_is_valid(name##_ref);
     64        int name##_add(name##_t *, const char *, const size_t, type *); \
     65        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); \
     69        int name##_initialize(name##_t *); \
     70        int name##_is_valid(name##_t *);
    7371
    7472/** Character string to generic type map implementation.
     
    8280        GENERIC_FIELD_IMPLEMENT(name##_items, type) \
    8381        \
    84         int name##_add(name##_ref map, const char *name, const size_t length, \
     82        int name##_add(name##_t *map, const char *name, const size_t length, \
    8583             type *value) \
    8684        { \
    87                 ERROR_DECLARE; \
     85                int rc; \
    8886                int index; \
    8987                if (!name##_is_valid(map)) \
     
    9290                if (index < 0) \
    9391                        return index; \
    94                 if (ERROR_OCCURRED(char_map_add(&map->names, name, length, \
    95                     index))) { \
     92                rc = char_map_add(&map->names, name, length, index); \
     93                if (rc != EOK) { \
    9694                        name##_items_exclude_index(&map->values, index); \
    97                         return ERROR_CODE; \
     95                        return rc; \
    9896                } \
    9997                return EOK; \
    10098        } \
    10199        \
    102         int name##_count(name##_ref map) \
     100        int name##_count(name##_t *map) \
    103101        { \
    104102                return name##_is_valid(map) ? \
     
    106104        } \
    107105        \
    108         void name##_destroy(name##_ref map) \
     106        void name##_destroy(name##_t *map) \
    109107        { \
    110108                if (name##_is_valid(map)) { \
     
    114112        } \
    115113        \
    116         void name##_exclude(name##_ref map, const char *name, \
     114        void name##_exclude(name##_t *map, const char *name, \
    117115            const size_t length) \
    118116        { \
     
    126124        } \
    127125        \
    128         type *name##_find(name##_ref map, const char *name, \
     126        type *name##_find(name##_t *map, const char *name, \
    129127            const size_t length) \
    130128        { \
     
    139137        } \
    140138        \
    141         int name##_initialize(name##_ref map) \
     139        int name##_initialize(name##_t *map) \
    142140        { \
    143                 ERROR_DECLARE; \
     141                int rc; \
    144142                if (!map) \
    145143                        return EINVAL; \
    146                 ERROR_PROPAGATE(char_map_initialize(&map->names)); \
    147                 if (ERROR_OCCURRED(name##_items_initialize(&map->values))) { \
     144                rc = char_map_initialize(&map->names); \
     145                if (rc != EOK) \
     146                        return rc; \
     147                rc = name##_items_initialize(&map->values); \
     148                if (rc != EOK) { \
    148149                        char_map_destroy(&map->names); \
    149                         return ERROR_CODE; \
     150                        return rc; \
    150151                } \
    151152                map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \
     
    153154        } \
    154155        \
    155         int name##_is_valid(name##_ref map) \
     156        int name##_is_valid(name##_t *map) \
    156157        { \
    157158                return map && (map->magic == GENERIC_CHAR_MAP_MAGIC_VALUE); \
Note: See TracChangeset for help on using the changeset viewer.