Changeset 8fb1bf82 in mainline for uspace/lib/c/include/adt/generic_char_map.h
- Timestamp:
- 2010-11-25T13:42:50Z (13 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/generic_char_map.h
ra93d79a r8fb1bf82 40 40 #include <unistd.h> 41 41 #include <errno.h> 42 #include <err.h>43 42 44 43 #include <adt/char_map.h> … … 56 55 \ 57 56 typedef struct name name##_t; \ 58 typedef name##_t *name##_ref; \59 57 \ 60 58 struct name { \ … … 64 62 }; \ 65 63 \ 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 *); 73 71 74 72 /** Character string to generic type map implementation. … … 82 80 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 83 81 \ 84 int name##_add(name##_ refmap, const char *name, const size_t length, \82 int name##_add(name##_t *map, const char *name, const size_t length, \ 85 83 type *value) \ 86 84 { \ 87 ERROR_DECLARE; \85 int rc; \ 88 86 int index; \ 89 87 if (!name##_is_valid(map)) \ … … 92 90 if (index < 0) \ 93 91 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) { \ 96 94 name##_items_exclude_index(&map->values, index); \ 97 return ERROR_CODE; \95 return rc; \ 98 96 } \ 99 97 return EOK; \ 100 98 } \ 101 99 \ 102 int name##_count(name##_ refmap) \100 int name##_count(name##_t *map) \ 103 101 { \ 104 102 return name##_is_valid(map) ? \ … … 106 104 } \ 107 105 \ 108 void name##_destroy(name##_ refmap) \106 void name##_destroy(name##_t *map) \ 109 107 { \ 110 108 if (name##_is_valid(map)) { \ … … 114 112 } \ 115 113 \ 116 void name##_exclude(name##_ refmap, const char *name, \114 void name##_exclude(name##_t *map, const char *name, \ 117 115 const size_t length) \ 118 116 { \ … … 126 124 } \ 127 125 \ 128 type *name##_find(name##_ refmap, const char *name, \126 type *name##_find(name##_t *map, const char *name, \ 129 127 const size_t length) \ 130 128 { \ … … 139 137 } \ 140 138 \ 141 int name##_initialize(name##_ refmap) \139 int name##_initialize(name##_t *map) \ 142 140 { \ 143 ERROR_DECLARE; \141 int rc; \ 144 142 if (!map) \ 145 143 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) { \ 148 149 char_map_destroy(&map->names); \ 149 return ERROR_CODE; \150 return rc; \ 150 151 } \ 151 152 map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \ … … 153 154 } \ 154 155 \ 155 int name##_is_valid(name##_ refmap) \156 int name##_is_valid(name##_t *map) \ 156 157 { \ 157 158 return map && (map->magic == GENERIC_CHAR_MAP_MAGIC_VALUE); \
Note:
See TracChangeset
for help on using the changeset viewer.