Changeset 32eceb4f in mainline for uspace/lib/c/generic/adt/char_map.c
- Timestamp:
- 2010-11-20T22:30:36Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cb59f787
- Parents:
- 1b22bd4 (diff), 7e1f9b7 (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/generic/adt/char_map.c
r1b22bd4 r32eceb4f 60 60 * @param[in] value The integral value to be stored for the key character 61 61 * string. 62 * @return sEOK on success.63 * @return sENOMEM if there is not enough memory left.64 * @return sEEXIST if the key character string is already used.62 * @return EOK on success. 63 * @return ENOMEM if there is not enough memory left. 64 * @return EEXIST if the key character string is already used. 65 65 */ 66 66 static int 67 char_map_add_item(char_map_ refmap, const char *identifier, size_t length,67 char_map_add_item(char_map_t *map, const char *identifier, size_t length, 68 68 const int value) 69 69 { 70 70 if (map->next == (map->size - 1)) { 71 char_map_ ref*tmp;72 73 tmp = (char_map_ ref*) realloc(map->items,74 sizeof(char_map_ ref) * 2 * map->size);71 char_map_t **tmp; 72 73 tmp = (char_map_t **) realloc(map->items, 74 sizeof(char_map_t *) * 2 * map->size); 75 75 if (!tmp) 76 76 return ENOMEM; … … 80 80 } 81 81 82 map->items[map->next] = (char_map_ ref) malloc(sizeof(char_map_t));82 map->items[map->next] = (char_map_t *) malloc(sizeof(char_map_t)); 83 83 if (!map->items[map->next]) 84 84 return ENOMEM; … … 107 107 * 108 108 * @param[in] map The character string to integer map. 109 * @return sTRUE if the map is valid.110 * @return sFALSE otherwise.111 */ 112 static int char_map_is_valid(const char_map_ refmap)109 * @return TRUE if the map is valid. 110 * @return FALSE otherwise. 111 */ 112 static int char_map_is_valid(const char_map_t *map) 113 113 { 114 114 return map && (map->magic == CHAR_MAP_MAGIC_VALUE); … … 127 127 * @param[in] value The integral value to be stored for the key character 128 128 * string. 129 * @return sEOK on success.130 * @return sEINVAL if the map is not valid.131 * @return sEINVAL if the identifier parameter is NULL.132 * @return sEINVAL if the length parameter zero (0) and the129 * @return EOK on success. 130 * @return EINVAL if the map is not valid. 131 * @return EINVAL if the identifier parameter is NULL. 132 * @return EINVAL if the length parameter zero (0) and the 133 133 * identifier parameter is an empty character string (the 134 134 * first character is the terminating zero ('\0') 135 135 * character. 136 * @return sEEXIST if the key character string is already used.137 * @return sOther error codes as defined for the136 * @return EEXIST if the key character string is already used. 137 * @return Other error codes as defined for the 138 138 * char_map_add_item() function. 139 139 */ 140 140 int 141 char_map_add(char_map_ refmap, const char *identifier, size_t length,141 char_map_add(char_map_t *map, const char *identifier, size_t length, 142 142 const int value) 143 143 { … … 172 172 * @param[in,out] map The character string to integer map. 173 173 */ 174 void char_map_destroy(char_map_ refmap)174 void char_map_destroy(char_map_t *map) 175 175 { 176 176 if (char_map_is_valid(map)) { … … 196 196 * zero (0) which means that the string is processed until 197 197 * the terminating zero ('\0') character is found. 198 * @return sThe node holding the integral value assigned to the key198 * @return The node holding the integral value assigned to the key 199 199 * character string. 200 * @return sNULL if the key is not assigned a node.201 */ 202 static char_map_ ref203 char_map_find_node(const char_map_ refmap, const char *identifier,200 * @return NULL if the key is not assigned a node. 201 */ 202 static char_map_t * 203 char_map_find_node(const char_map_t *map, const char *identifier, 204 204 size_t length) 205 205 { … … 224 224 } 225 225 226 return map;226 return (char_map_t *) map; 227 227 } 228 228 … … 239 239 * zero (0) which means that the string is processed until 240 240 * the terminating zero ('\0') character is found. 241 * @return sThe integral value assigned to the key character string.242 * @return sCHAR_MAP_NULL if the key is not assigned a value.243 */ 244 int char_map_exclude(char_map_ refmap, const char *identifier, size_t length)245 { 246 char_map_ refnode;241 * @return The integral value assigned to the key character string. 242 * @return CHAR_MAP_NULL if the key is not assigned a value. 243 */ 244 int char_map_exclude(char_map_t *map, const char *identifier, size_t length) 245 { 246 char_map_t *node; 247 247 248 248 node = char_map_find_node(map, identifier, length); … … 267 267 * zero (0) which means that the string is processed until 268 268 * the terminating zero ('\0') character is found. 269 * @return sThe integral value assigned to the key character string.270 * @return sCHAR_MAP_NULL if the key is not assigned a value.271 */ 272 int char_map_find(const char_map_ refmap, const char *identifier, size_t length)273 { 274 char_map_ refnode;269 * @return The integral value assigned to the key character string. 270 * @return CHAR_MAP_NULL if the key is not assigned a value. 271 */ 272 int char_map_find(const char_map_t *map, const char *identifier, size_t length) 273 { 274 char_map_t *node; 275 275 276 276 node = char_map_find_node(map, identifier, length); … … 281 281 * 282 282 * @param[in,out] map The character string to integer map. 283 * @return sEOK on success.284 * @return sEINVAL if the map parameter is NULL.285 * @return sENOMEM if there is not enough memory left.286 */ 287 int char_map_initialize(char_map_ refmap)283 * @return EOK on success. 284 * @return EINVAL if the map parameter is NULL. 285 * @return ENOMEM if there is not enough memory left. 286 */ 287 int char_map_initialize(char_map_t *map) 288 288 { 289 289 if (!map) … … 295 295 map->next = 0; 296 296 297 map->items = malloc(sizeof(char_map_ ref) * map->size);297 map->items = malloc(sizeof(char_map_t *) * map->size); 298 298 if (!map->items) { 299 299 map->magic = 0; … … 319 319 * @param[in] value The integral value to be stored for the key character 320 320 * string. 321 * @return sEOK on success.322 * @return sEINVAL if the map is not valid.323 * @return sEINVAL if the identifier parameter is NULL.324 * @return sEINVAL if the length parameter zero (0) and the321 * @return EOK on success. 322 * @return EINVAL if the map is not valid. 323 * @return EINVAL if the identifier parameter is NULL. 324 * @return EINVAL if the length parameter zero (0) and the 325 325 * identifier parameter is an empty character string (the 326 326 * first character is the terminating zero ('\0) character. 327 * @return sEEXIST if the key character string is already used.328 * @return sOther error codes as defined for the char_map_add_item()327 * @return EEXIST if the key character string is already used. 328 * @return Other error codes as defined for the char_map_add_item() 329 329 * function. 330 330 */ 331 331 int 332 char_map_update(char_map_ refmap, const char *identifier, const size_t length,332 char_map_update(char_map_t *map, const char *identifier, const size_t length, 333 333 const int value) 334 334 { 335 char_map_ refnode;335 char_map_t *node; 336 336 337 337 node = char_map_find_node(map, identifier, length);
Note:
See TracChangeset
for help on using the changeset viewer.