Changeset ad7a6c9 in mainline for uspace/lib/c/include/adt/generic_char_map.h
- Timestamp:
- 2011-03-30T13:10:24Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/generic_char_map.h
r6e50466 rad7a6c9 47 47 #define GENERIC_CHAR_MAP_MAGIC_VALUE 0x12345622 48 48 49 /** Generic destructor function pointer. */ 50 #define DTOR_T(identifier) \ 51 void (*identifier)(const void *) 52 49 53 /** Character string to generic type map declaration. 50 54 * @param[in] name Name of the map. … … 62 66 }; \ 63 67 \ 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 *); \ 65 69 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); \ 69 73 int name##_initialize(name##_t *); \ 70 74 int name##_is_valid(name##_t *); … … 74 78 * Should follow declaration with the same parameters. 75 79 * 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 * 78 83 */ 79 84 #define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \ 80 85 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 81 86 \ 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, \ 83 88 type *value) \ 84 89 { \ 85 int rc; \86 90 int index; \ 87 91 if (!name##_is_valid(map)) \ … … 90 94 if (index < 0) \ 91 95 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); \ 98 97 } \ 99 98 \ … … 104 103 } \ 105 104 \ 106 void name##_destroy(name##_t *map ) \105 void name##_destroy(name##_t *map, DTOR_T(dtor)) \ 107 106 { \ 108 107 if (name##_is_valid(map)) { \ 109 108 char_map_destroy(&map->names); \ 110 name##_items_destroy(&map->values ); \109 name##_items_destroy(&map->values, dtor); \ 111 110 } \ 112 111 } \ 113 112 \ 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)) \ 116 115 { \ 117 116 if (name##_is_valid(map)) { \ … … 120 119 if (index != CHAR_MAP_NULL) \ 121 120 name##_items_exclude_index(&map->values, \ 122 index ); \121 index, dtor); \ 123 122 } \ 124 123 } \ 125 124 \ 126 type *name##_find(name##_t *map, const char*name, \125 type *name##_find(name##_t *map, const uint8_t *name, \ 127 126 const size_t length) \ 128 127 { \
Note:
See TracChangeset
for help on using the changeset viewer.