Changes in uspace/lib/c/generic/adt/char_map.c [1bfd3d3:2544442] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/char_map.c
r1bfd3d3 r2544442 60 60 * @param[in] value The integral value to be stored for the key character 61 61 * string. 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.62 * @returns EOK on success. 63 * @returns ENOMEM if there is not enough memory left. 64 * @returns EEXIST if the key character string is already used. 65 65 */ 66 66 static int 67 char_map_add_item(char_map_ t *map, const char *identifier, size_t length,67 char_map_add_item(char_map_ref 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_ t **tmp;72 73 tmp = (char_map_ t **) realloc(map->items,74 sizeof(char_map_ t *) * 2 * map->size);71 char_map_ref *tmp; 72 73 tmp = (char_map_ref *) realloc(map->items, 74 sizeof(char_map_ref) * 2 * map->size); 75 75 if (!tmp) 76 76 return ENOMEM; … … 80 80 } 81 81 82 map->items[map->next] = (char_map_ t *) malloc(sizeof(char_map_t));82 map->items[map->next] = (char_map_ref) 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 TRUE if the map is valid.110 * @return FALSE otherwise.111 */ 112 static int char_map_is_valid(const char_map_ t *map)109 * @returns TRUE if the map is valid. 110 * @returns FALSE otherwise. 111 */ 112 static int char_map_is_valid(const char_map_ref 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 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 the129 * @returns EOK on success. 130 * @returns EINVAL if the map is not valid. 131 * @returns EINVAL if the identifier parameter is NULL. 132 * @returns 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 EEXIST if the key character string is already used.137 * @return Other error codes as defined for the136 * @returns EEXIST if the key character string is already used. 137 * @returns 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_ t *map, const char *identifier, size_t length,141 char_map_add(char_map_ref 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_ t *map)174 void char_map_destroy(char_map_ref 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 The node holding the integral value assigned to the key198 * @returns The node holding the integral value assigned to the key 199 199 * character string. 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,200 * @returns NULL if the key is not assigned a node. 201 */ 202 static char_map_ref 203 char_map_find_node(const char_map_ref map, const char *identifier, 204 204 size_t length) 205 205 { … … 224 224 } 225 225 226 return (char_map_t *)map;226 return 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 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;241 * @returns The integral value assigned to the key character string. 242 * @returns CHAR_MAP_NULL if the key is not assigned a value. 243 */ 244 int char_map_exclude(char_map_ref map, const char *identifier, size_t length) 245 { 246 char_map_ref 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 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;269 * @returns The integral value assigned to the key character string. 270 * @returns CHAR_MAP_NULL if the key is not assigned a value. 271 */ 272 int char_map_find(const char_map_ref map, const char *identifier, size_t length) 273 { 274 char_map_ref 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 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)283 * @returns EOK on success. 284 * @returns EINVAL if the map parameter is NULL. 285 * @returns ENOMEM if there is not enough memory left. 286 */ 287 int char_map_initialize(char_map_ref map) 288 288 { 289 289 if (!map) … … 295 295 map->next = 0; 296 296 297 map->items = malloc(sizeof(char_map_ t *) * map->size);297 map->items = malloc(sizeof(char_map_ref) * 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 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 the321 * @returns EOK on success. 322 * @returns EINVAL if the map is not valid. 323 * @returns EINVAL if the identifier parameter is NULL. 324 * @returns 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 EEXIST if the key character string is already used.328 * @return Other error codes as defined for the char_map_add_item()327 * @returns EEXIST if the key character string is already used. 328 * @returns 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_ t *map, const char *identifier, const size_t length,332 char_map_update(char_map_ref map, const char *identifier, const size_t length, 333 333 const int value) 334 334 { 335 char_map_ t *node;335 char_map_ref node; 336 336 337 337 node = char_map_find_node(map, identifier, length);
Note:
See TracChangeset
for help on using the changeset viewer.